(CNN)Malaysians woke Thursday to the shocking news that former Prime Minister Mahathir Mohamad had kicked his one-time protege, Najib Razak, out of office, ending six decades of dominance by the ruling coalition.
Mahathir Mohamad: Malaysia's comeback prime minister
Making things more confusing for outsiders is the fact Mahathir himself was responsible for much of that dominance, as strongman leader of the Barisan Nasional coalition during his 22 years in power from 1981 to 2003.
At 92, when sworn in Mahathir will be the world's oldest leader, 21 years older than US President Donald Trump, twice the age of Canadian Prime Minister Justin Trudeau.
Credited with turning Malaysia into a major trading and economic force in Southeast Asia, Mahathir left politics in 2003, but he returned with a vengeance this year, determined to oust the incumbent prime minister, Najib.
Mahathir told CNN in January that standing in the election was a "job I have to do."
"I cannot accept this country being destroyed by selfish people who only think about themselves ... who steal money," he said, referencing the 1MDB corruption scandal which has dogged Najib's premiership.
US justice officials said that between 2009 and 2015, more than $3.5 billion from 1MDB was misappropriated by high-level officials of the board and associates.
With Najib's most potent rival, former Deputy Prime Minister Anwar Ibrahim, behind bars after being convicted on corruption and sodomy charges, the opposition was looking weak going into the election.
That was before Mahathir joined the fray, saying he didn't mind "being used by the opposition" to oust Najib.
The nonogenerian said he would step aside in Anwar's favor after securing his former rival a royal pardon, clearing him to serve as prime minister.
Anwar's wife, Wan Azizah, endorsed Mahathir and served as his deputy in the coalition to oust Najib. She was one of the dozens of opposition candidates elected Wednesday.
"I am 92 going on 93," Mahathir said in January. "I won't last long and I am prepared for that. But for as long as I can contribute, I will continue, and I will back Anwar if that is the wish of the party."
Mahathir's embrace of Anwar Ibrahim has surprised many. When Mahathir was prime minister in the 1990s, Anwar was jailed on sodomy and corruption charges that critics said were politically motivated.
Anwar remains imprisoned after being found guilty of sodomy a second time in 2015 under Najib -- a charge he has also said is politically motivated. He's expected to be released in June, after serving the bulk of the sentence.
For Mahathir and 70-year-old Anwar, this election was likely their last roll of the dice.
Anwar taking the premiership through an election won by Mahathir would only months ago have seemed absurd, but it now seems to be very much on the cards, with Najib, once the consummate political survivor, on the way out.
Malaysians will likely be in for days, if not weeks and months, of uncertainty, as a ruling coalition is hashed out and it is decided how and when Mahathir will step aside for Anwar or another opposition figure.
"The greatest litmus test of Mr. Mahathir's commitment to the (opposition) is if he hands over power to Mr. Anwar, as he promised," said Fung Siu, regional manager for Asia at the Economist Intelligence Unit.
She pointed out under Malaysia's political system, even after he receives a royal pardon, Anwar will still have to win a seat in parliament before he can take the premiership.
"A leadership change would unsettle financial markets, particularly if the process were to become long-drawn and turn acrimonious," Fung added.
As the former head of Barisan Nasional, Mahathir served 22 years as the country's leader before retiring in 2003.
A former physician, known as "Dr. M" by the public, he joined the United Malays National Organization (UNMO) in 1946, just over a decade before the country won its independence from the UK. UNMO became the dominant party in the Barisan coalition.
He was first elected prime minister in 1981, serving until October 2003, when he stepped aside for his anointed successor Abdullah Ahmad Badawi.
In retirement, Mahathir was a constant critic of Abdullah, though his barbs were nothing compared to his subsequent attacks on Najib.
During his decades in power, Mahathir ruled as a strongman leader and frequently used the draconian Internal Security Act to go after critics and enemies.
Indeed, many of the problems with Malaysian politics criticized by Mahathir and his allies in their campaign against Najib were put in place by the former leader, according to Yang Razali Kassim, a senior fellow at the S. Rajaratnam School of International Studies (RSIS).
"It is ironic that the man who crushed the opposition while in power has remade himself in retirement as the de facto leader of what in essence is a citizens' revolt," he said ahead of the vote.