Mahathir, prime minister for 22 years until 2003, emerged from political retirement and joined the opposition in an attempt to oust Prime Minister Najib Razak, his former protege, after a multibillion-dollar corruption scandal at state investment fund 1MDB set up by Najib. "There are candidates who had so much money remaining to hand out but did not manage to give all", claimed Mahathir.
Najib's ruling Barisan Nasional (BN) coalition is seen as likely to retain power mainly due to an electoral system critics say has been heavily manipulated to favour the government, but analysts predict the government will lose the popular vote for the second consecutive election.
The controversy surrounding 1MDB has dogged Najib since the story exploded in 2015.
Peter Mumford, an analyst with Eurasia Group, a political risk consultancy for investors, said the credibility of Malaysia's institutions has been "torn to pieces" by Najib's election tactics.
When he takes power, Mahathir will be the oldest prime minister in the world.
The opposition has been reinvigorated by Mahathir after fracturing in 2015 when its most charismatic figure, Anwar Ibrahim, was imprisoned on charges of sodomy in a case he and his supporters said was manufactured by the government to crush the opposition.
"The time for change has come, and I hope the people in power realise this", said Asifa Hanifah, a young woman who joined thousands of opposition supporters in central Kuala Lumpur who waved flags, cheered and honked vehicle horns.
Votes were still being counted after the closely-fought poll and the Election Commission did not confirm Mahathir had won.
At the last election, BN lost the majority vote in its worst performance ever, but pulled in 133 seats.
Top Chinese economic adviser to visit United States next week for trade talks
China responded with threats of US exports to China in an equal amount and targeting industries that may cause the most impact. Its imports from the United States rose 20.3 percent, the fastest growth in three months.
Under Najib, the ruling coalition's prestige has been eroded by the 1MDB corruption scandal and an unpopular sales tax that hit poor rural Malays particularly hard.
The opposition also made strong gains in Sarawak state on Borneo island, a long-time BN stronghold. But in a blow to his ruling bloc, the leaders of its Chinese and Indian component parties both lost their seats, according to Bernama.
"The likelihood is that they will not be forming the government", he told reporters, referring to Najib's coalition.
He said the opposition had achieved the number of seats needed to win the election.
Mahathir won his seat on the holiday island of Langkawi while Najib won his in the constituency of Pekan, according to unofficial tallies. Its candidate for prime minister is 92-year-old former Prime Minister Mahathir Mohamad.
He said the commission will investigate complaints that ballot papers didn't reach some postal voters in time and that some were invalid because they weren't stamped as official. Deputy Prime Minister Ahmad Zahid Hamidi said in The Star that Mahathir should be "taking care of his grandkids" instead of staying in politics.
Among the key election issues has been the rising cost of living in the country, with many voters placing blame on the goods and services tax that was imposed three years ago.
Momentum for the opposition has been gathering, and experts believe that will narrow the margin of victory for Najib.
"I believe this speech showed the level of uncertainty and insecurity of the government and Najib (Razak) has come to the extreme", Dr. Lemiere said, adding that the ruling government had been passing laws by force - such as the anti-fake news law and the electoral re-delineation law.