Malaysian ex-leader Mahathir Mohamad, 92, has been invited to form the next government and will be sworn in later Thursday, a palace statement said, after a shock election win against the country's long-ruling coalition.
Mahathir's opposition alliance scored a surprise victory at the polls to break the grip on power of the Barisan Nasional (BN) coalition, which has governed Malaysia uninterrupted since its birth as an independent country in 1957.
It capped a dramatic comeback for Mahathir, who ruled the country with an iron fist for 22 years and came out of retirement to take on Prime Minister Najib Razak after the leader became embroiled in a massive corruption scandal.
A palace statement said King Sultan Muhammad V had "decided to invite Tun Dr Mahathir to form the next federal government," using a Malaysian honorific.
The king will swear in Mahathir as prime minister at 9:30 pm (1330 GMT), it added.
Earlier, Mahathir and his wife Siti Hasmah Mohamad Ali were driven into the national palace in Kuala Lumpur for an audience with the king, passing hundreds of supporters waving flags and chanting the national anthem.
Mohamad Azlan Shah, a member of Mahathir's party among the crowd, said he was "very proud" of the former leader's victory.
"Our struggle to change Malaysian politics is not wasted. We believe Mahathir can make a change," he told AFP.
One of the most remarkable aspects of Mahathir's comeback has been his reconciliation with jailed opposition icon Anwar Ibrahim, his former nemesis, a relationship that has loomed large over the Malaysian political landscape for decades.
Anwar was Mahathir's heir apparent until the premier sacked him in 1998 over political differences, and he was subsequently jailed on charges of sodomy and abuse of power that were widely seen as trumped-up.
Anwar was jailed again during Najib's rule but he is due out in June -- and Mahathir has promised to secure him a royal pardon, allowing him to run for office again and potentially become prime minister.
As it became clear that BN was facing a historic wipeout, Najib kept a low profile before surfacing Thursday morning to tell a press conference that he accepted the people's will, although he stopped short of conceding defeat.
His comments were slammed by one analyst as "unstatesmanlike".
The opposition's shock victory triggered euphoria and a sense of relief that a leader who was accused of massive graft and fanning racial tensions in the multi-ethnic country was finally on his way out.
"We have been waiting for so long for this to happen," said Larson Michael, 35, a voter from just outside Kuala Lumpur.
"(Mahathir) has come back to help us regain the country. Now we want to see if he will fulfil his promises."
The initial delight at the opposition victory will likely give way to some apprehension. Mahathir was also accused of being an authoritarian leader, and political opponents were thrown in jail during his time in office.
The opposition faced an uphill battle at the election due to what critics said were no-holds-barred attempts by Najib to hang on to power.
His government was accused of gerrymandering while activists said he hurled cash and gifts at voters and there was a litany of problems with the electoral roll, including dead people appearing on the list.
In the event, voters turned out in droves across the country to oust Najib.
His defeat could be just the start of his problems -- Mahathir has vowed to bring him to justice over allegations that billions of dollars were looted from sovereign wealth fund 1MDB, which the scandal-hit leader set up and oversaw. He has denied any wrongdoing.
In Mahathir, the opposition found the perfect person to take on Najib. He is a staunch Malay nationalist who could appeal to the country's biggest ethnic group, and whose years in power were remembered as a prosperous period in the country's history.