Mahathir fired Anwar in the late 90s and oversaw his first jail conviction. He has been in hospital for a few months recovering from a shoulder operation. Najib has said the deposit was a donation by an unnamed member of the Saudi royal family which had been largely returned.
The pardons board in Malaysia's capital will meet this week to discuss Anwar's release and Mahathir said he would be released the same day.
Malaysian Prime Minister Mahathir Mohammad on Tuesday said he will remain in office for at least one to two years.
Anwar said that after working with Mahathir for many years he understands "that he cares deeply about Malaysia and the people of Malaysia".
Anwar, the opposition's de facto leader who is now in jail for a sodomy conviction considered to be politically-charged, agreed to work with his former enemy Mahathir.
The volatile relationship between Mahathir and Anwar has dominated Malaysia's political landscape for over three decades and is central to the future of the alliance.
Mahathir was asked in an interview by video link whether a deal could be cut with Najib, who is alleged to have overseen the looting of government investment fund 1MDB.
Mahathir sacked Anwar as his deputy prime minister in 1998.
Supreme Eurasian Economic Council to convene in Sochi on 14 May
We highly appreciate Russia's balanced position during Armenia's internal political crisis. Nevertheless, the Kremlin clearly remained skeptical of Pashinyan's intentions.
Anwar's prison sentence ends June 8, but without a royal pardon he would be barred from politics for five years. "Anwar bin Ibrahim", said a statement issued by the palace.
Anwar's freedom is expected to ease fears of a growing rift within the newly formed coalition government, after differences erupted between supporters of Mahathir and Anwar over cabinet positions and Anwar's role in the party.
"The first question I am taking is from TV3", he joked, alluding to the fact that the TV station had carried a lot of negative stories about him and other Pakatan Harapan (PH) leaders in the past before the pact took over Putrajaya.
Anwar's political triumphs and legal tribulations have riveted and appalled Malaysians since the 1990s, when he soared to national power as a talented deputy prime minister but then fell spectacularly, only to rise from the ashes in the opposition.
It was a shared desire to remove scandal-ridden former-PM Najib Razak that forged the unlikely alliance between Anwar and Dr Mahathir, who came out of retirement to bring down his former protege.
He maintains his innocence, and says on both occasions Mahathir and Najib turned to trumping up charges against him to keep him out of politics.
"Seeing him walk free makes me emotional, but the fight is not over", said Ridzuan Ismail, an Anwar supporter at the hospital. Mahathir on Saturday named the finance, home affairs and defense ministers, who are leaders in his four-party alliance. Mr Apandi cleared Mr Najib of any wrongdoing in connection with the misappropriation of billions of dollars from 1MDB.
The former prime minister has been blocked from leaving the country and a complaint has been filed against him to the Malaysian Anti-Corruption Commission alleging he personally blocked an investigation into the US$3.2bn 1MDB scandal.