Malaysia's current monarch swore in Anwar Ibrahim as PM on Thursday.
Ibrahim, 75, had been deputy PM and finance minister for much of the 1990s.
Was imprisoned in 1998 on sodomy charges after split with then-PM Mahathir Mohamed.
Released in 2004, was again imprisoned for sodomy in 2015 as Najib Razak led country.
Was released in 2018 after a renewed alliance with Mahathir, who again became PM.
Malaysia's Anwar Ibrahim was finally sworn in as prime minister on Thursday, capping a three-decade political journey that has seen him cast as esteemed protege, protest leader, prisoner twice convicted of sodomy and opposition leader.
The 75-year-old Anwar has time and again been denied the premiership despite getting within striking distance over the years: he was deputy prime minister in the 1990s and the official prime minister-in-waiting in 2018.
His appointment ends five days of unprecedented post-election crisis after no coalitions earned a majority. King Al-Sultan Abdullah then appointed Anwar after speaking to several lawmakers.
Here's a closer look at the new prime minister, who has spent about a decade of his life in prison.
Cast out, beaten in custody
Anwar started off as a firebrand Islamic youth leader before joining former prime minister Mahathir Mohamed's United Malays National Organisation (UMNO), which leads the Barisan Nasional alliance of political parties.
Mahathir, prime minister since 1981, made Anwar his deputy a dozen years later, in addition to his existing role as finance minister. As a result, Anwar was widely expected to one day succeed Mahathir.
But the pair fell out after disagreeing over how to handle the Asian financial crisis, with Anwar also questioning corruption in the Mahathir-led UMNO.
In 1998, Mahathir fired Anwar and, amid the ensuing protests, launched a crackdown on dissent. Anwar was charged with sodomy, a crime in Malaysia, a move he said aimed to put an end to his political career.
Anwar was unfit to lead "because of his character," Mahathir said.
Anwar appeared at his sodomy trial with a black eye, which then became the symbol of the political party he started. Later, the police chief at the time admitted to having assaulted Anwar in prison.
Anwar was freed in 2004, only to be jailed again for sodomy and corruption charges in 2015, two years after leading the opposition to its best electoral performance until then. On that occasion, Anwar's supporters placed blame on the government of then-prime minister Najib Razak.
When Razak was defeated in 2018, in a remarkable comeback for then-92-year-old Mahathir, Anwar was freed again. Mahathir and Anwar had patched up their differences ahead of the campaign politically, and it was expected that Anwar would eventually take the leadership reins, given Mahathir's age.
"I have forgiven him, he has proved his mettle. Why should I harbour any malice towards him?" Anwar said at the time.
Meanwhile, Razak has since been imprisoned in the massive, international 1MDB scandal, in which billions in public money went missing.
What comes next
As premier, Anwar will have to address soaring inflation and slowing growth as the economy recovers from the coronavirus pandemic. The most immediate issue will be the budget for next year, which was tabled before the election was called but has yet to be passed.
Anwar will also have to negotiate agreements with lawmakers from other blocs to ensure he can retain majority support in parliament.
"Anwar is appointed at a critical juncture in Malaysian history, where politics is most fractured, recovering from a depressed economy and a bitter COVID memory," said James Chai, visiting fellow at ISEAS-Yusof Ishak Institute in Singapore.
Anwar failed to win a majority in the Nov. 19 election, and standing in his way could be the leader of the mostly conservative ethnic-Malay, Muslim alliance that garnered the second-most seats, Muhyiddin Yassin.
Muhyiddin's bloc includes the Islamist party PAS, whose electoral gains raised concern among members of the ethnic Chinese and ethnic Indian communities, most of whom follow other faiths.
Anwar's supporters expressed hope that his government would head off a return to historic tension between the ethnic Malay, Muslim majority and ethnic Chinese and Indian minorities.
"All we want is moderation for Malaysia and Anwar represents that," said a communications manager in Kuala Lumpur, who asked to be identified by her surname Tang.
Authorities warned after last week's vote of a rise in ethnic tension on social media and short video platform TikTok said it was on high alert for content that violated its guidelines.
Mathahir, 97, loses seat
Anwar told Reuters in an interview before the election that he would seek "to emphasize governance and anti-corruption, and rid this country of racism and religious bigotry" if appointed.
The decision in the end came down to the king. The constitutional monarch plays a largely ceremonial role but can appoint a premier he believes will command a majority in parliament.
Malaysia has a unique constitutional monarchy in which kings are chosen in turn from the royal families of nine states to reign for a five-year term.
Mathahir, it should be noted, ran for a parliamentary seat again. Now 97, he finished fourth out of five candidates in the Langkawi riding.