Rival blocs claimed on Sunday they had secured the support they needed to form a government after Malaysia's hotly contested poll saw no party emerge with a clear majority of parliamentary seats.
Veteran opposition leader Anwar Ibrahim said his coalition had enough seats to form the country's next government, which would allow him to become prime minister.
Former premier Muhyiddin Yassin -- who heads the rival Perikatan Nasional (National Alliance) grouping -- also said he was in talks to form the next government after Saturday's election.
The stalemate comes in a country that has seen three governments change in as many years.
Home to 33 million people, Malaysia will need a ruling coalition with a strong mandate to tackle soaring food prices and an economy reeling from the Covid-19 pandemic.
While both leading political blocs claimed victory, neither offered details on the alliances they would make to form the government.
"We have now the majority to form a government," Anwar said at a dawn news conference after hours of frenzied horse-trading negotiations through the night.
When pressed about who would enter into an alliance with him, Anwar did not name names, but said commitments had been made in writing and would be submitted to the king for endorsement.
At the end of vote-counting, Anwar's Pakatan Harapan (Alliance of Hope) coalition won 82 seats and Muhyiddin's Perikatan Nasional grabbed 73, official results showed.
- Islamist party gains -
The once mighty Barisan Nasional -- dominated by jailed ex-leader Najib Razak's United Malays National Organisation (UMNO) party -- trailed far behind the rest with only 30 seats, its worst performance since Malaysia won independence in 1957.
The graft-tainted bloc said it accepted the results and that it was a "big signal from the citizens towards us."
The election also saw the rise of an Islamist party allied with Muhyiddin's group. The Malaysian Islamic Party, or PAS, backs a hardline interpretation of Islamic law.
Ethnic Malay parties have campaigned on a platform that claims that members of Malaysia's majority ethnicity would lose their rights if non-Malays -- such as Anwar's multi-ethnic bloc -- are elected.
Oh Ei Sun of the Pacific Research Centre of Malaysia said if Muhyiddin gets to form the government, the country is "likely to see a conservative theocratic coalition that will focus on religious and racial supremacy at the expense of effective economic management".
"Perikatan Nasional's strong message of clean government was able to make inroads into UMNO's vote bank and captured key UMNO seats," said Asrul Hadi Abdullah Sani, deputy managing director at BowerGroupAsia.
One of the highest profile losses in the election was former prime minister Mahathir Mohamad, 97, who was roundly defeated in his constituency.
- Anwar's last chance -
Anwar campaigned on a promise to fight corruption, after Najib's ruling party was tainted by a spate of graft cases, including one that sent the former prime minister to jail for 12 years.
A perennial runner-up in Malaysian politics, Anwar endured two prison terms and had been on the cusp of power several times in his political career.
Voter turnout in Sunday's election was high -- two hours before polling closed, it was already at 70 percent -- and those who spoke to AFP said they hoped for political stability and economic improvement.
The results represented the latest electoral humiliation for UMNO, after it suffered a stunning defeat in the 2018 general election due to anger over the 1MDB scandal.
Najib was at the centre of that storm and was jailed over his role in it.
Because of infighting in the two successive governments since 2018, UMNO crept back into power last year, despite lingering corruption allegations, and had sought a stronger mandate from this election.
Corruption was a key issue during the campaign, with opposition parties repeatedly warning that if UMNO won, Najib could walk free and graft charges against other party leaders could be dropped.
The 1MDB scandal -- in which billions of dollars in state funds were diverted to Beverly Hills properties, a superyacht, a Hollywood film and Najib's own bank account -- sparked investigations in Singapore, Switzerland and the United States.