In this file photo (then) Malaysian Prime Minister Mahathir Mohamad waves good bye to media after a press conference in Putrajaya on April 15, 2019. AP
Mahathir came in fourth in a five-way fight in his long-held constituency in the holiday resort island of Langkawi, the country's election commission said.
It was his first electoral defeat in more than half a century.
Mahathir held the Guinness World Record for being the "world's oldest current prime minister" when he became premier for a second time in 2018 just two months shy of his 93rd birthday.
Visibly slowed by age but still looking healthy, he ran this time around under his own Homeland Fighters' Party and had laughed off suggestions he should retire, telling reporters before the election he had a "good chance" of winning.
"I'm still standing around and talking to you, I think, making reasonable answers," Mahathir said.
He added his party would not form any alliances with parties that are led by "crooks or jailbirds" -- an apparent reference to the United Malays National Organisation (UMNO), the party of jailed former prime minister Najib Razak.
"Mahathir's time has passed"
Mahathir has been criticised for ruling the Southeast Asian nation with an iron fist from 1981 to 2003 but is also hailed for helping transform the country from a sleepy backwater into one of the world's top exporters of high-tech goods.
Mahathir's long leadership provided political stability and he gained the title of "Father of Modern Malaysia" as he oversaw the construction of highways and industrial parks in the 1980s and 1990s.
He came out of his 15-year retirement to lead the opposition Pakatan Harapan (Alliance of Hope) coalition in the 2018 polls amid voter anger over then incumbent Najib's role in the massive financial scandal at state fund 1MDB.
The reformist bloc won a stunning victory over UMNO and Najib, who was later convicted of corruption and is currently serving a 12-year jail sentence.
Mahathir became premier again but his government collapsed in less than two years due to infighting.
He has warned that Najib would be freed if the jailed politician's allies in UMNO win.
He also offered to become prime minister a third time, but observers said he had no chance from the beginning.
His titanic clashes with opposition leader Anwar Ibrahim, his erstwhile heir-in-apparent with whom he had a bitter falling out, have dominated and shaped Malaysian politics over the past two decades.
In the end, age was his biggest opponent.
"Mahathir's time has passed," Bridget Welsh of the University of Nottingham Malaysia told AFP earlier this month ahead of the election.