By A. Ananthalakshmi, Mei Mei Chu and Rozanna Latiff
KUALA LUMPUR (Reuters) - Malaysia's Anwar Ibrahim was sworn in as prime minister on Thursday, capping a three-decade political journey from a protege of veteran leader Mahathir Mohamad to protest leader, a prisoner convicted of sodomy and opposition leader.
Anwar, 75, vowed to fight corruption and to focus on the economy while also upholding Islam as the official religion of the multi-ethnic country and defending special rights of ethnic Malays.
"Thank God, because we have seen a change that has awaited the people of Malaysia," Anwar told reporters at a late-evening address, hours after he was sworn in by the king who appointed him following an inconclusive election.
"We will never compromise on good governance, the anti-corruption drive, judicial independence and the welfare of ordinary Malaysians," he said before leading chants of "Reformasi" - his rallying cry for reform during years of opposition.
U.S. Secretary of State Antony Blinken congratulated Anwar and said Americans looked forward to deepening the two nations' friendship and cooperation based on shared democratic principles and respect for human rights and the rule of law.
"We remain committed to working with Malaysia to advance a free and open, connected, prosperous, secure, and resilient Indo-Pacific region," Blinken said in a statement.
Anwar's appointment ends five days of unprecedented post-election crisis, but could usher in further instability with his rival, former prime minister Muhyiddin Yassin, challenging him to prove his majority in parliament.
Both men's coalitions failed to win a majority in a Saturday election, but Malaysia's constitutional monarch, King Al-Sultan Abdullah, appointed Anwar after speaking to several lawmakers.
Anwar takes over at a challenging time, with the economy slowing and the country divided after a tight election.
The campaign pitted Anwar's progressive, multi-ethnic coalition against Muhyiddin's mostly conservative ethnic-Malay, Muslim alliance.
Markets surged on the end of political deadlock. The ringgit currency posted its best day in two weeks and equities rose 3%.
Anwar had 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.
In between, he spent nearly a decade in jail for sodomy and corruption in what he says were politically motivated charges aimed at ending his career.
The uncertainty over the election threatened to prolong political instability in the Southeast Asian country, which has had three prime ministers in as many years, and risks delaying policy decisions needed to foster economic recovery.
Anwar's supporters expressed hope that his government would avert a return to historic tensions 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.
"We can't have a country that is divided by race and religion as that will set us back another 10 years."
Anwar's coalition, known as Pakatan Harapan, won the most seats in Saturday's vote with 82, while Muhyiddin's Perikatan Nasional bloc won 73. They needed 112 - a simple majority - to form a government.
The long-ruling Barisan bloc won only 30 seats - the worst electoral performance for a coalition that had dominated politics since independence in 1957.
Barisan said on Thursday it would not support a government led by Muhyiddin, though it made no reference to Anwar.
Muhyiddin's bloc includes the Islamist party PAS, whose electoral gains raised concern within the ethnic Chinese and Indian communities, most of whose members follow other faiths.
Authorities warned after the weekend 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.
Social media users reported numerous TikTok posts since the election that mentioned a riot in the capital, Kuala Lumpur, on May 13, 1969, in which about 200 people were killed, days after opposition parties supported by ethnic Chinese voters made inroads in an election.
The decision on the prime minister came down to King Al-Sultan Abdullah, after both Anwar and Muhyiddin missed his Tuesday afternoon deadline to put together a ruling alliance.
The king 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.
The most immediate issue facing Anwar will be the budget for next year, which was proposed 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.
"Always regarded as the man who could unite all warring factions, it is fitting that Anwar emerged during a divisive time."
(Reporting by A. Ananthalakshmi, Mei Mei Chu and Rozanna Latiff; additional reporting by Lucia Mutikani in Washington; Editing by Kanupriya Kapoor, Robert Birsel, Raissa Kasolowsky, Gareth Jones and Daniel Wallis)