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 after 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.
His 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 MPs.
Anwar's supporters expressed hope that his government would avert a return to historical 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 although it made no reference to Anwar.
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 MPs from other blocs to ensure he can retain majority support in parliament.