Mahathir Mohamad was sworn in as the world's oldest prime minister late on Thursday evening, making an extraordinary political comeback as Malaysia's leader at the age of 92.

Supporters waved flags and cheered outside the Istana Negara palace in the capital, Kuala Lumpur, as Dr Mahathir, who previously served as prime minister for 22 years, took the oath once again.

The ceremony took place at 9.30pm after a day of political drama that began in the early hours with Dr Mahathir's opposition coalition trouncing Najib Razak, the incumbent prime minister, and his ruling Barisan Nasional coalition (BN), in a shock election victory.

Mr Najib waited until mid-morning to grudgingly accept defeat, but he immediately cast doubt on his former mentor's right to be appointed prime minister, declaring that only the king, as head of state, had the authority to make that choice.

Hours of unexplained delays in Dr Mahathir's appointment heightened fears that the transition of power, after ousting a coalition that had ruled Malaysia for over sixty years, would not be smooth.

The former political strongman urged Yang di-Pertuan Agong, the country's monarch, to allow him to form a government by 5pm, warning that any delay would mean you "have no government, you have no law, you have no constitution."