Malaysia's perennial opposition leader Anwar Ibrahim was named prime minister on Thursday, ending a days-long political impasse after inconclusive election results.
The 75-year-old was scheduled to be sworn in at 5 pm (0900 GMT), becoming the country's fourth leader in as many years.
His ascension will cap a turbulent political life for Anwar, during which he has sat near the apex of power, as well as serving jail time on corruption and sodomy charges.
"After taking into consideration the views of Their Royal Highnesses the Malay Rulers, His Majesty has given consent to appoint Anwar Ibrahim as the 10th Prime Minister of Malaysia," read a statement from the palace of the king, Sultan Abdullah Ahmad Shah.
Anwar's multi-ethnic Pakatan Harapan coalition won the most seats in the weekend's election, on an anti-graft message.
But its total of 82 seats was short of the required 112.
The king had summoned Anwar and former prime minister Muhyiddin Yassin— whose Perikatan Nasional bloc got 73 seats— in an attempt to break the deadlock, but no deal could be struck.
Muhyiddin, who was backed by an Islamist party, told reporters Tuesday that the monarch had initially asked him and Anwar to form a "unity government".
For Anwar, the premiership is the culmination of a rollercoaster 25 years.
The firebrand former student activist was close to power in the late 1990s, as finance chief and deputy prime minister to Mahathir Mohamad.
But the two had a bitter falling-out over how to handle the 1997-98 Asian financial crisis.
Mahathir sacked Anwar, who was also expelled from their then party the United Malays National Organisation (UMNO), and charged with corruption and sodomy.
Anwar was sentenced to six years in jail for corruption in 1999, with an additional nine years added for the sodomy charge the following year, the two sentences to run consecutively.
As Anwar claimed political persecution, street protests erupted and evolved into a movement calling for democratic reforms.
The Mahathir-Anwar tussle has dominated and shaped Malaysian politics over the past four decades, "alternately bringing despair and hope, progress and regress to the country's polity", according to Oh Ei Sun of the Pacific Research Center of Malaysia.
The Malaysian Supreme Court overturned Anwar's sodomy conviction in 2004 and ordered him freed.
Anwar allied with Mahathir during the 2018 elections, when his erstwhile tormentor came out of retirement to challenge incumbent Najib Razak, who was mired in the billion-dollar 1MDB financial scandal.
Their alliance scored a historic victory against UMNO and Najib, who is now serving a 12-year jail term for corruption.
Mahathir became prime minister for the second time, with an agreement to hand over the premiership to Anwar later.
He never fulfilled that pact, and their alliance collapsed after 22 months, leaving Anwar empty-handed again.
"This is a long time coming for Anwar Ibrahim," Asrul Hadi Abdullah Sani, deputy managing director at strategic advisory firm Bower Group Asia, told AFP.
"One of his agendas is to ensure he is able to fulfil his reform agenda as he looks to stabilise a loosely cobbled federal coalition."