Scandal-plagued Najib, 64, was thrashed at the polls by a coalition of parties led by Mahathir, who led the country for 22 years and came out of retirement to challenge Najib in the country's 14th general election.
The defeat is a humiliating fall from grace for Najib, the scion of one of Malaysia's most prominent political families, and his coalition party, Barisan Nasional, which had led the country since its independence 61 years ago.
With all 222 seats in the country's Parliament accounted for, Mahathir's coalition had officially won 121 seats -- enough to form a simple majority and take control of the House. Barisan Nasional, in contrast, only had 79 seats -- a far cry from the 133 it won in the 2013 election.
The bloodbath did not end there -- Najib also saw several members of his Cabinet, ministers and deputy ministers, defeated at the polls, and crashed out of eight of the battles for control of 12 state legislatures contested in the election.
According to a statement by the country's Election Commission, over 76% of the 14.3 million eligible voters in the country turned out to cast their ballots, which opened at 8 a.m. local time and went on until 5 p.m. The turnout was lower than the 85% the country saw in 2013.
While the defeat surely spells the end of Najib's political career, for Mahathir, it represents the culmination of a stunning return to power, a decade-and-a-half after retirement.
Mahathir's victory is all the more remarkable considering he is 92 years old, and was fighting the very party he led for over two decades.
Bridget Welsh, a John Cabot University expert on Malaysian politics, said Barisan Nasional could have won the elections had it not been for Najib.
"Najib is a liability. His narcissism cost them the elections," she said, of a Barisan Nasional campaign that featured Najib and his election promises as a centrepiece.
Welsh added Najib's re-election campaign never really took off.
"He used racial politics and money, like he did in 2013, but it did not have the same traction.
"This was a Malaysian tsunami across races, generations and background."
James Chin, the director at the Asia Institute in the University of Tasmania, said Najib had "finally run out of tricks" and said Mahathir had pulled off a masterstroke in snatching the rural vote away from Najib.
He compared the campaign speeches given by the two men on Tuesday night, hours before voting began. "Najib was still playing the bribery game -- you give me your vote, I give you this or that. Mahathir, on the other hand, came across as a statesman and appealed to Malay dignity," he said.
Chin called out two things that helped turn the tide against Najib -- a high voter turnout and the swing in rural support.
"Even if the rural voters didn't understand 1MDB, they understood that some monkey business was happening. And so the Najib brand became toxic," he said.
Comeback for Anwar?
One of the twists of the election came in the form of Mahathir's embrace of Anwar Ibrahim, his former deputy and later political foe, whom he once jailed on sodomy and corruption charges critics said were politically motivated
Anwar remains imprisoned after being found guilty of sodomy a second time in 2015 -- a charge he has also said is politically motivated. He's expected to be released in June, after serving the bulk of the sentence.
Prior to the election Mahathir pledged he would step aside for Anwar, after securing him a royal pardon. Mahathir has pledged only to serve two years before handing over to his former rival.
Calling it an "unprecedented" alliance in Malaysian politics, Welsh told CNN before the election the two former political enemies had "not only a strategic (alliance) but one based on an idea of statesmanship, of moving the country in a different direction.
"It speaks a lot to the character of both Mahathir and Anwar that they can come together," she said.
"I don't think it's been easy for either of them. For Mahathir he's had to face some of the things he's done, and to apologize. For Anwar, it's to go along with someone who's created a lot of harm to his family."
A contentious election
Najib had been under massive pressure
in the run up to the elections, chiefly due to long-running allegations of corruption and misappropriation of money from a state fund, known as the 1Malaysia Development Berhad, but also because of deeply unpopular moves such as the introduction of a goods and services tax (GST), which many Malaysians feel has caused the cost of living to spike sharply.
The elections have been contentious. Najib came under fire from opposition parties and civil society groups for a redrawing of electoral lines
that skewed constituencies heavily in favor of his ruling coalition, towards the rural ethnic Malay-Muslim voters that have traditionally formed Barisan Nasional's power base, and away from the urban voters that have largely abandoned his coalition.
Najib also rammed through a bill in Parliament, days before it was dissolved and elections were called, that was ostensibly targeted at curbing the spread of fake news
, but which critics said was aimed at stifling free speech and dissenting voices. Mahathir has become one of the first people to be investigated under the law.
There was also deep unhappiness at the fact that the elections were held on a weekday -- only the fifth time in the country's history such a thing has happened
, and the first time in the country's history it was held in midweek. Many believed that the choice to have it on a weekday was a deliberate attempt to suppress the number of votes cast.
The country's Election Commission also came under significant fire, with overseas voters furious about the length of time it took them to get their postal voting ballots. Malaysians in London staged a protest
earlier this week excoriating the commission for the late arrival of their ballot papers.
Election day controversies
Polling day came with its own share of controversies. Voters in some areas were turned away by election officials for wearing shorts and flip-flops, despite a statement from the Electoral Commission's chairman the day before that there wouldn't be a dress code for voters.
There were also allegations of discrepancies in voting papers
, with some voters who turned up to cast their ballots told that they had already voted.
Earlier in the day, opposition politicians claimed their phones and email accounts had been hacked and spammed
, saying it was a deliberate attempt to disrupt their communications.
Vote counting by officials went on into the morning, with final results still pending. Najib and Prime Minister-elect Mahathir are expected to address the nation early Thursday. And for the rest of the country, the party has already begun -- May 10 and May 11 have already been declared public holidays in celebration of one of the most remarkable moments in Malaysia's modern history.