Official results from Malaysia's national election show the opposition alliance led by the country's former leader Mahathir Mohamad and jailed opposition leader Anwar Ibrahim has won a majority in parliament, ending the 60-year rule of the National Front.
The Election Commission says the opposition has so far won 115 seats -- over the threshold of 112 seats needed in parliament to form a government.
The opposition is also sweeping state elections, including Johor state where the dominant Malay party in the National Front was founded.
Mahathir, who at age 92 will become the world's oldest prime minister, said Wednesday a representative of the monarchy had contacted the opposition acknowledging the election victory.
Malaysian voters have been angered by a multibillion-dollar corruption scandal at a state investment fund set up by Prime Minister Najib Razak and new taxes.
"We are not seeking revenge, we want to restore the rule of law," Mahathir told reporters, as he declared victory.
Anwar, who was jailed in 2015 on charges widely believed to be politically motivated, joined forces with Mahathir to oust the corrupt Najib.
"There is a massive swing across races. It's a big shift. This is a repudiation of Najib's government from all walks of life from the very rural northern states to the more industrial southern coast," said Bridget Welsh, a Southeast Asia expert at John Cabot University in Rome.
"The person who has made this happen is Mahathir. He has been a significant game changer. He made people feel that a transition of power is possible," said Welsh, who is in Kuala Lumpur to observe the polls.
Angered by the graft scandal, Mahathir, who was prime minister for 22 years until 2003, emerged from political retirement and joined the opposition in attempt to oust Najib, his former protege.
The U.S. Justice Department says $4.5 billion was looted from 1MBD, the investment fund, by associates of Najib between 2009 and 2014, including $700 million that landed in Najib's bank account. He denies any wrongdoing.
Analysts had previously said the National Front, which has been in power for 60 years, might lose the popular vote but hold onto a majority in parliament due to an electoral system that gives more power to rural Malays, the party's traditional supporters.
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.
Faced with a reinvigorated opposition, the government has used the levers of power to further tilt the playing field in its favor, critics and analysts say. Redrawn electoral boundaries were rushed through parliament last month, pushing likely opposition voters into seats that already support the opposition and dividing constituencies along racial lines. A recently passed "fake news" law was an attempt to stifle debate and criticism, opponents said.
The National Front lost its two-thirds majority in parliament in 2008 polls and lost the popular vote in 2013, though it still won 60 percent of seats that year.