KUALA LUMPUR: Malaysia's new Prime Minister Anwar Ibrahim said his swearing in was a change that Malaysians have waited for and pledged to keep Islam as the official religion of the country.

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.

The longtime opposition leader was sworn in 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'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.