It was a remarkable comeback for Mahathir, who was premier for 22 years until his retirement in 2003.
"I take this opportunity to wish health and success for Your Eminence and prosperity and glory for the Malaysian nation from God", Rouhani added in his message.
Najib's coalition suffered a shocking electoral defeat this week that ended its 60 year-rule.
Nazir called Malaysia a new icon of democracy, saying it had "defied the odds and global trends with this peaceful transition to power in line with the will of the people".
Mahathir previously said he would likely remain prime minister for two to three years, before transferring power to Anwar.
In the past, Nazir has criticised the "New Economic Policy" introduced by his late father in 1971, saying it had deviated from its original objective to eradicate poverty irrespective of race and eliminate identification of economic function with ethnicity.
The scandal became a major factor in the election and in the ouster of Najib Razak, Mahathir's predecessor and former protege. In 1999 - during Mahathir's first tenure as Prime Minister - he was imprisoned on charges of abusing his power.
Khloe Kardashian Says She's "Mentally Strong" After Cheating Scandal
The 33-year-old reality star and new mom shared a couple of videos on her social media pages to mark True's one-month birthday. Khloe Kardashian has finally revealed her daughter, True Thompson , as she turns one month old today, Saturday, May 12, 2018.
Mahathir also said he had replaced the country's attorney general, who had cleared Najib of all wrongdoing in the 1MDB scandal.
Mahathir is expected to announce his cabinet line-up later on Saturday.
U.S. investigators said Najib's associates stole and looted Dollars 4.5 billion from the fund, of which some USD 700 million landed in Najib's bank account and some USD 30 million used to buy jewelry for his wife. A statement released by the royal palace ahead of the ceremony said the Sultan invited Mahathir to form the next federal government.
Mahathir, now the world's oldest elected leader at 92, has said his government would not go seek revenge over the 1MDB fiasco but that Najib would have to face the court if he was found to be responsible.
In the latest dizzying development after last week's shock poll results, Mahathir announced Friday that the king has agreed to pardon jailed leading politician Anwar Ibrahim, his former nemesis turned ally.
Anwar is in custody on charges of sodomy and corruption and can not take any office until he is pardoned and released.
He was accompanied by his wife Siti Hasmah Mohamad Ali and other leaders in the opposition alliance, including Wan Azizah Wan Ismail, whom Mahathir pledged to tap as the deputy prime minister.