Kuala Lumpur (CNN) Veteran Malaysian politician Mahathir Mohamad has become the world's oldest leader after a shock victory in the country's election, upending six decades of control by the ruling coalition.

The 92-year-old was sworn in on Thursday night by Malaysia's constitutional ruler, King Muhammad V, following a momentous vote in which scandal-plagued incumbent Najib Razak was soundly beaten at the polls by his former mentor.

It's a triumphant return to front-line Malaysian politics for Prime Minister Mahathir, who also ruled the country from 1981 until 2003.

He was sworn in by the Malaysian head of state at about 9:50 p.m. (9.50 a.m. ET). It followed a day of confusion over the status of Malaysia's new government, with various times announced and then missed for Mahathir's official appointment.

His car was seen driving into the palace ahead of a possible 5 p.m. meeting, only for it to leave again an hour and a half later.

But in a press statement issued on Thursday night, the palace said it had invited Mahathir to form a government and "strongly" denied the king had delayed the appointment.

"His Majesty the King strongly supports and respects the democratic process," the statement said.

Mahathir Mohamad celebrates with his coalition leaders during a press conference in Kuala Lumpur on May 10.

Political survivor

Mahathir, who governed the country for 22 years as strongman leader of the Barisan Nasional coalition, came out of retirement to challenge the incumbent in the country's 14th general election.

In January, Mahathir said that running was "a job I have to do," in an exclusive interview with CNN.

The veteran politician's coalition won 121 seats, enough to form a simple majority and take control of the House. Barisan Nasional, the coalition that has led the country since independence, only won 79 seats, a far cry from the 133 it won in the 2013 election.

Supporters of Former Malaysian prime minister Mahathir Mohamad celebrate outside the National Palace.

Ousted Malaysian Prime Minister Najib had earlier conceded defeat.

Acknowledging the electoral bloodbath that saw his ruling Barisan Nasional coalition lose over 50 seats, Najib said that he accepted the "will of the people," but also trumpeted the achievements of his government.

Despite the thrashing at the polls, Najib's speech appeared to tease the possibility that the identity of the country's next leader was not a foregone conclusion.

"Because no party got a simple majority, the King will decide whom to appoint as Prime Minister ... Barisan Nasional will accept the King's decision, and I urge all Malaysians to accept the decision calmly and place their faith in the King to make a wise decision."

Outgoing Malaysian prime minister Najib Razak of the Barisan National party coalition arrives to address the media after his coalition's loss.

Pardon for former nemesis?

In his first press conference since his stunning win over Barisan Nasional, Mahathir said that he would move quickly to end an unpopular sales tax, and said that among his first acts would be to arrange for a pardon for his political ally -- and one-time political nemesis -- Anwar Ibrahim, to allow him to re-enter politics.

Anwar remains imprisoned after being found guilty of sodomy in 2015 -- the second time he's been imprisoned for the offense. He has long said that the charges are politically motivated.

He's expected to be released in June, after serving the bulk of the sentence. Mahathir has previously pledged to seek a royal pardon, which would potentially pave the way for him to succeed the elderly Mahathir in just a couple of years.

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.

Asked about his other promise made during the campaign to pursue a corruption investigation into Najib, Mahathir maintained the former leader would be subject to the rule of law.

"If the law says Najib has done something wrong, then he will have to face the consequences," he said.

He added that a recent, controversial fake news law widely seen as a political tool to quash dissent would go under review. Ahead of the election, Mahathir himself was one of the first targeted under the law.

"I cannot accept this country being destroyed by selfish people who only think about themselves ... who steal money."

Najib's negative campaign and charges that he influenced the redistricting of constituencies to bolster his chances were compounded by long-running accusations of corruption, mostly stemming from a state fund, known as the 1Malaysia Development Berhad, commonly known as 1MDB.

Supporters of Mahathir Mohamad cheer as they watch live televised result announcement in Kuala Lumpur.

Najib was also under fire 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 defeated former leader 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.

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 would not 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 Wednesday, opposition politicians claimed their phones and email accounts had been hacked and spammed, saying it was a deliberate attempt to disrupt their communications.