next Image 1 of 2

prev Image 2 of 2

Known as an authoritarian leader who ruthlessly persecuted his foes and stifled dissent, Mahathir Mohamad was an unlikely choice to steer Malaysia on a more democratic path.

But the pugnacious politician, remarkably robust at age 92, pulled off a stunning electoral upset on Wednesday, denying his former protege Najib Razak a third term as prime minister and ending the ruling National Front's 60-year hold on power.

It was a feat many predicted was impossible. Malaysia's election this week was expected to provide more evidence that democracy in Southeast Asia was in an inexorable retreat. Instead, it became a powerful beacon for people power.

Mahathir is now the world's oldest elected leader and, analysts say, seems intent on using what may be the final chapter of his life to clean up Malaysia — he called it a "mess" — and fashion a more positive legacy.

"I was very sleepy this morning," he joked at a lively post-election news conference Thursday. "I got up late and lots of people got up late. The moment I got up, as I was having breakfast, I called all the officers concerned and told them all things we have to do."

Mahathir was a maverick Malay nationalist in the early days of his political career who survived expulsion from the dominant United Malays National Organization party, and became the first commoner prime minister of Malaysia. Though credited with transforming the Southeast Asian backwater into a modern economy, his dominance, like that of his contemporary, Lee Kuan Yew in Singapore, was stifling.

Under his 22-year rule, the judiciary was a tool of the government, the media were muzzled and a system of economic privileges for the Malay majority and second-class status for Chinese and Indian minorities remained entrenched.

Among the stains of his years in power was the sacking of his deputy, Anwar Ibrahim, following a power struggle. Anwar led street protests against Mahathir but was imprisoned on charges of sodomy and corruption and appeared in court with a black eye from a police beating.

Mahathir had extravagant ambitions for Malaysia's economy, backing the construction of the famous twin Petronas Towers in Kuala Lumpur that were once the world's tallest buildings and creating state-owned carmaker Proton, which never really prospered despite being sheltered from competition.

Not long before his retirement in 2003, Mahathir caused global outrage with an anti-Semitic speech to leaders of Islamic nations that portrayed Jews as leading a global conspiracy to oppress Muslims.

Even after stepping down, he remained influential, smoothing Najib's ascent to the top in 2009 after criticizing his first successor, Abdullah Ahamad Badawi, for poor economic management. He also supported Najib in 2013 elections.

Then he became Najib's most ferocious critic as the prime minister, initially regarded as a cautious reformer, turned to Mahathir's authoritarian playbook to survive a multibillion-dollar corruption scandal at the 1MDB state fund that damaged the country's reputation.

The United States and several other countries are investigating allegations of cross-border embezzlement and money laundering at 1MDB, which was set up and previously led by Najib to promote economic development. The U.S. Justice Department says at least $4.5 billion was stolen from 1MDB by associates of Najib, who denies any wrongdoing.

Mahathir publicly reconciled with Anwar, again in prison on another sodomy charge he said was fabricated by the National Front, and joined the multi-ethnic opposition to "save Malaysia" from a corrupt elite.

Despite two coronary bypass surgeries, Mahathir kept up a hectic campaign schedule. He sometimes spoke several times a day at rallies and also updated his tactics for the social media age.

He was rapturously welcomed at opposition rallies and seemed to relish poking fun at the plutocratic Najib, describing him as someone who would try to buy his way into heaven but who'd be sent to hell.

When he wasn't invited to a forum that planned to debate whether at well past 90 years he was too old to be prime minister again, he turned up anyway.

"As far as health is concerned, I am not senile yet," he announced to the stunned participants, many of whom stood and snapped photos with their smartphones.

For good measure, Mahathir sat in the front row and tweeted: "I'm here guys. Say it to my face."

The move was trademark Mahathir, his appetite for political brawling apparently unsated.

Ahead of being sworn in as prime minister again, he promised to seek a full royal pardon for Anwar, criticized a represssive "fake news" law introduced under Najib but didn't say it would be repealed, and vowed to cancel an unpopular goods and service tax.

There are hopes that as a powerful figure for the ethnic Malay majority he will have political capital to reform the loaded electoral system that kept the National Front in power for six decades and pare back the system of economic privileges for Malays. It remains unclear what, if anything, he would do in those areas.

"I don't know about not liking me. I'm a very nice person," he joked when a reporter asked about rumors Malaysia's king, who swore him in as prime minister on Thursday evening, doesn't look kindly on him.

"I have the support of the majority of the members of parliament," Mahathir said. "That is what the provision of the constitution states. It doesn't say I like you or I don't like you, I love you or not."