Two weeks ago, Malaysia's Najib Razak was supremely confident of being elected prime minister for a third term. Instead, in a dizzying political drama, he lost an unlosable election and spiraled into ever-deepening disgrace while Malaysians are being feted for advancing democratic values against their global retreat.

In a series of humiliations, the patrician and luxury-loving Najib and wife Rosmah Mansor were banned from leaving the country; truckloads of luggage stashed with cash and valuables as well as hundreds of expensive designer bags were seized from their home and other properties; and anti-corruption police questioned Najib for hours this week about a multibillion-dollar corruption scandal on his watch.

After 60 years of uninterrupted National Front rule, many Malaysians are optimistic they are ushering in an era of reform that echoes the democratic transformation of giant neighbor Indonesia two decades earlier. The difference, they hope, is that it will continue to be accomplished without setting their multiethnic country in flames. A grouping of progressive Southeast Asian lawmakers has hailed Najib's defeat as a "bright spot amid dark times" of rising authoritarianism across the region.

The May 9 election that turfed Najib and his government despite an electoral system heavily engineered in their favor was a "quiet, dignified but defining revolution at the ballot box," said Malaysian rights activist and lawyer Ambiga Sreenevasan. "Malaysia has now set the gold standard in Southeast Asia for bringing change peacefully even through a flawed process," said Sreenevasan, who has been appointed by the new government to a reform panel.

Najib's ouster was in large part made possible by the return to politics of Mahathir Mohamad, premier for 22 years until 2003. Spurred by anger over the alleged looting of state investment fund 1MDB by associates of Najib, he emerged from retirement and joined with former political enemies to campaign against the ruling coalition.

Despite Mahathir being mocked by Najib for his old age and authoritarian record, his reputation as a statesman who transformed a Southeast Asian backwater into a modern economy helped soothe voters' fears of possible chaos under a new government. Many Malaysians have been haunted for decades by racial riots in 1969 that killed more than 200 people.

Since he was sworn in as Malaysia's seventh premier and the world's oldest leader at 92, Mahathir has wasted no time in setting up his government and tackling the country's financial problems. Former foes he once jailed have been appointed to the cabinet, including the first ethnic Chinese to hold the powerful finance ministry post in 44 years. Malaysia also now has its first female deputy prime minister.

Mahathir facilitated a royal pardon that freed reformist icon Anwar Ibrahim, who was jailed in 2015 in what he said was a conspiracy by Najib to crush his opposition alliance. Anwar, who is now the prime minister-in-waiting, was sacked by Mahathir in 1998 after a power struggle and jailed for sodomy and corruption. The two men reconciled in 2016, united by their resolve to oust Najib.

Mahathir has said he needs one to two years to restore order before handing power to Anwar.

The top priority is getting to the bottom of the 1MDB scandal.

Najib started the fund when he took power in 2009 but it accumulated billions in debts. U.S. investigators say $4.5 billion was stolen and laundered from 1MDB by his associates, some of which landed in Najib's bank account and $27.3 million of it used to buy a rare pink diamond necklace for his wife.

A former attorney general and senior anti-graft official, who were on the verge of pressing criminal charges against Najib in 2015 before they, respectively, were sacked and fled in fear of arrest, have been brought back to help investigate. A 1MDB panel has been set up to liaise with foreign countries on how to retrieve the laundered billions.

New Finance Minister Lim Guan Eng said Tuesday that Najib's government had conducted "an exercise of deception" over 1MDB and also misrepresented the country's financial situation to parliament. The same day, the anti-corruption commission official who previously led investigations into 1MDB gave a harrowing account of how the probe was suppressed by intimidation during Najib's rule.

"Malaysia will likely be one of the few Southeast Asian nations to put a former PM in jail," said Bridget Welsh, political science professor at the John Cabot University in Rome, who was in Kuala Lumpur to observe the polls.

Najib "made the mistake of thinking it was about him rather than the office he held," she said. Former Philippine President Joseph Estrada was jailed for corruption in 2007.

While the 1MDB crisis will keep officials busy, there are other worries for Mahathir and the new government.

Closer examination of the election results showed many from the country's ethnic Malay majority still didn't support Mahathir's alliance.

The conservative Pan-Malaysian Islamic Party made major gains by winning control of two rural northeastern mainly Malay states. Collectively with the National Front, they hold 43 percent of seats in Parliament.

This could create difficulty for Mahathir's government on any attempt to pare back a decades-old affirmative action policy that favors Malays in government contracts, business, jobs, education and housing.

The program is credited with lifting millions of Malays out of poverty and creating an urban middle class of the ethnic group who account for two-thirds of Malaysia's 31 million people. But it is also blamed for a racial divide between Malays and minority Chinese and Indians who have long complained about government discrimination.

Many ethnic minorities left Malaysia over the years in search of better opportunities but the vote has revived a sense of nationalism, with social media awash with Malaysians hailing Mahathir as a "hero" and expressing pride in being part of a "reborn Malaysia."

Anwar, a Malay, told The Associated Press in an interview after his release that the race-based policies should be discarded in favor of a merit program that helps all poor irrespective of race.

Once the election euphoria fades, he said the government has to prove there will be more freedom, good governance and a better life for all Malaysians.

"Conservative forces are still strong," said Welsh, a Southeast Asia expert and poll observer. "Mahathir has made important steps so far that showcase a reform orientation. Malaysians place a lot of hope in his continued leadership. His harnessing of nationalism is important to overcome more divisive currents."