Malaysia was facing a hung parliament for the first time in its history as support for a conservative Islamic alliance prevented major coalitions from winning a simple majority in a general election.
Without a clear winner, political uncertainty could persist as Malaysia faces slowing economic growth and rising inflation. It has had three prime ministers in as many years.
Failure by the main parties to win a majority means a combination of them would have to build a majority alliance to form a government. Malaysia's constitutional monarch may also get involved, as he has the power to appoint as Prime Minister a lawmaker whom he believes can command a majority.
Longtime opposition leader Anwar Ibrahim's coalition won the most seats in Saturday's general election, results from the Election Commission showed.
The biggest surprise came from former premier Muhyiddin Yassin who led his Perikatan Nasional bloc to a strong showing, pulling support from the incumbent government's traditional strongholds.
Muhyiddin's alliance includes a Malay-centric conservative party and an Islamist party that has touted shariah or Islamic law. Race and religion are divisive issues in Malaysia, where the Muslim ethnic-Malay population make up the majority and ethnic Chinese and Indians the minorities.
Both Anwar and Muhyiddin claimed to have the support to form government, though they did not disclose which parties they had allied with.
Muhyiddin said he hoped to finish discussions by Sunday afternoon. His alliance is a junior partner in incumbent Prime Minister Ismail Sabri Yaakob's ruling coalition and could work with them again.
Anwar said he would submit a letter to Malaysia's King Al-Sultan Abdullah detailing his support.
If Anwar clinches the top job, it would cap a remarkable journey for a politician who, in 25 years, went from heir apparent, to the premiership, to a prisoner convicted of sodomy to the country's leading opposition figure.
Malaysia has 222 parliamentary seats but polls were held only for 220 on Saturday.
The Election Commission said Anwar's multi-ethnic Pakatan Harapan coalition won a total of 82 seats, while Muhyiddin's Perikatan Nasional alliance won 73 seats. Ismail's Barisan coalition got 30. One seat was unannounced as of 2100 GMT.
"The key takeaway from this election is that Perikatan has successfully disrupted the two party system," said Adib Zalkapli, a director with political consultancy Bower Group Asia.
Barisan and Pakatan have long been Malaysia's main blocs.
Barisan said it accepted the people's decision, but stopped short of conceding defeat. The coalition said in a statement it remains committed to forming a stable government.
Veteran leader Mahathir Mohamad meanwhile was dealt his first election defeat in 53 years in a blow that could mark the end of a seven-decade political career, losing his seat to Muhyiddin's alliance.
A record number of Malaysians voted on Saturday, hoping to end a spate of political uncertainty that has resulted in three prime ministers amidst uncertain economic times and the COVID-19 pandemic.
The political landscape has been rocky since Barisan lost the 2018 election after governing for 60 years from independence.
Anwar was released from prison in 2018 after joining with old foe Mahathir and Muhyiddin to defeat Barisan for the first time in Malaysia's history, amid public anger at the government over the multibillion-dollar 1MDB scandal.
That coalition collapsed after 22 months in power due to infighting over a promise by Mahathir to hand the premiership to Anwar. Muhyiddin briefly became premier, but his administration collapsed last year, paving the way for Barisan's return to power with Ismail at the helm.