The stunning turn of events come amid plans by Mahathir's supporters in his Bersatu party to team up with opposition parties to form a new government and thwart the transition of power to his named successor, Anwar Ibrahim.
Minutes before Mahathir tendered his resignation to the palace, Bersatu said it would leave the four-party Alliance of Hope and support Mahathir as prime minister. Eleven other lawmakers, including several Cabinet ministers, announced they were quitting Anwar's party to form an independent bloc.
Bersatu later said Mahathir had also quit as party chairman. The withdrawal of more than three dozen lawmakers means the ruling alliance has lost its majority in Parliament, throwing the country into an uncertain future and sparking fears of more turmoil over how the political drama will play out.
King Sultan Abdullah Sultan Ahmad Shah, who met leaders from the new faction on Sunday and both Anwar and Mahathir on Monday, accepted Mahathir's resignation, the chief secretary to the government, Mohamad Zuki Ali, said in a statement.
Mohamad Zuki said the king also decided Mahathir should continue as interim leader until a new prime minister is chosen and a new Cabinet formed. He said the king also dissolved the Cabinet on Mahathir's advice, essentially sealing the breakup of the current government.
The king's decision helped bring some political stability to the country after the series of dizzying events unraveled Sunday with maneuvers aimed at keeping Mahathir in power and blocking Anwar from the top job. Horse trading is expected as both factions scramble to build enough support to take power.
Anwar said Monday after meeting with Mahathir and with other alliance leaders that Mahathir was not involved in the conspiracy and had quit because he didn't want to be associated with the former corrupt regime that he worked hard to oust in the 2018 polls.
"His name was used, by those within my party and outside," Anwar told reporters. Mahathir "reiterated to me what he had said earlier, that he played no part in it and he made it very clear, that in no way will he ever work with those associated with the past regime."
Anwar said he pleaded with Mahathir to stay on to jointly defeat the conspirators but he refused.
Anwar was Mahathir's deputy during Mahathir's first stint as prime minister but they fell out politically. The pair reunited in a political pact in the May 2018 election, which ousted a ruling coalition that has governed the country since independence from Britain in 1957. Tension has erupted as Mahathir refused to set a date to relinquish power despite a preelection agreement to hand over power to Anwar.
The political plot by the defectors would include an alliance with the Malay party of disgraced former leader Najib Razak, who with several of his party leaders are standing trial on corruption charges. It would also recruit a fundamentalist Islamic party that rules two states and champions Islamic laws. The two Malay parties still have strong support from ethnic Malays, who account for 60% of Malaysia's 32 million people.
The political drama came just two days after all of the parties in the now-crumbling alliance agreed that Mahathir alone should decide when he would step down after Malaysia hosts an Asia-Pacific regional meeting in November.
Mahathir has remained silent, but many Malaysians reacted with dismay and shock, saying moves to form a "backdoor" government would be unethical and that a new election should be called.
Electoral watchdog group Bersih, which has organized several protest rallies in the past, warned it would organize a mass rally if an undemocratic government is formed. Bersih and about three dozen civil society groups said democracy was in peril and demanded the defectors quit and new elections be called.
Analysts said a new "backdoor" government could give rise to Malay Islamic supremacy that would derail Malaysia's multi-ethnic society.
"If the new government goes through, Malaysia is heading toward a very regressive stage whereby racial supremacy and religious extremism would become the rule of the day," said Oh Ei Sun, a senior fellow at the Singapore Institute of International Affairs.