MPs applauded as Anwar took the oath of office following his weekend local election victory, a sight that would have been unthinkable just months ago when he was an opposition leader languishing behind bars.
The former deputy premier's remarkable political resurrection was triggered by his alliance's shock election victory in May, which toppled a corruptionriddled coalition that had ruled Malaysia for six decades.
Following the triumph, Anwar was pardoned and released from jail, where had been imprisoned since 2015 on widely criticised sodomy charges, and is now the presumptive successor to the country's leadership.
Mahathir, 93, has pledged to hand power to Anwar within two years. The deal was struck when the pair, whose upanddown relationship has long loomed over Malaysian politics, formed an unlikely alliance to take on the government of Najib Razak.
Anwar needed to be elected as an MP again to succeed Mahathir, and he cruised to a thumping victory in Saturday's poll in Port Dickson, where his opponents included a former aide whose sodomy accusations landed him in jail.
It is the first time that Mahathir who, during a first stint as premier, sacked Anwar and had him thrown in jail and his former foe have been in the same government since the 1990s.
Anwar, wearing a tradiฌtional black Muslim cap, brushed aside questions about when he will become premier, and insisted he would let Mahathir have "the space, the latitude" to get on with governing.
"That's very important because some of the decisions that have to be made by the prime minister and the cabinet are key, fundamental decisions of policy," the 71yearold told reporters.
He also insisted he would not take up a cabinet position.
After their fallout, Anwar became a prominent opposition leader at the head of a reformist alliance. But Mahathir himself turned on the party he once headฌed as corruption allegations mounted against Najib, and later teamed up with Anwar.
Since his defeat, Najib has been charged over the alleged plundering of state fund 1MDB. He denies any wrongdoing.