Mr Anwar, who was formerly Dr Mahathir's political rival, has been promised leadership of Malaysia's new governing coalition when Dr Mahathir, 92, decides to step down.
Anwar served as Dr Mahathir's deputy and finance minister before being removed from his post and incarcerated on sodomy and corruption charges, which human rights groups and foreign governments criticised as being politically motivated.
As he left the hospital, Anwar waved at the large crowd of journalists and supporters gathered outside the facility but did not say anything to them.
Anwar emerged from the Cheras Rehabilitation Hospital on Wednesday after Malaysia's Pardon Board, which included the current King, chose to overturn the 2015 conviction, which is widely accepted to be politically motivated.
PKR party leader Mohamed Azmin Ali told reporters outside the hospital that Anwar and his wife Wan Azizah Wan Ismail are heading straight to the palace for an audience with the king, Sultan Muhammad V.
Anwar, whose sodomy conviction is believed by supporters to have been concocted by Najib to derail the opposition, is expected to be pardoned by the country's king on Wednesday and released.
Mahathir sacked Anwar as his deputy prime minister in 1998.
"If there is no case, we don't go for detention without trial", he said.
HTC Announces Plans For A Blockchain Smartphone
CryptoCurrency? Well, HTC thinks there's a lot of interest in it, so much so they're developing a blockchain friendly smartphone. In terms of specifications, the Finney blockchain phone comes with a Qualcomm Snapdragon 845 processor.
Anwar was initially scheduled to be released on June 10, 2018, after his five-year sentence that started on Feb 10, 2015 was reduced for good behaviour.
"(In) an initial stage, maybe lasting one or two years, I will be the prime minister", Mahathir said in an interview with The Wall Street Journal CEO Council in Tokyo via a video link from Malaysia on Tuesday.
Malaysiakini news website noted the declassified report lacks details due to the fund's refusal to provide complete documentation, but for key parts which were investigated, the information corroborates with that of the US Department of Justice.
"I will continue to ensure that the current prime minister (Dr Mahathir Mohamad) fulfils the promises for reforms he has made and we will ensure there are proper checks and balances".
Tensions within the ruling coalition, which are likely given differences between Mr Mahathir and Mr Anwar in the past, would raise doubts about the ability of the administration to deliver. On Monday, he said he would meet party leaders again to discuss the Cabinet formation but reiterated in clear terms that as prime minister, he will make the final decision, a statement that could make his relationship with Anwar uneasy. It regrouped as the Alliance of Hope, but it was Mahathir's political comeback and his embrace by Anwar's party that helped seal the opposition's victory.
Najib was chairman of the RM42 billion debt-laden state fund 1MDB, from which funds were allegedly misappropriated to acquire assets globally, resulting in investigations in seven countries.
Dr Mahathir reiterated there are no charges against Najib, and that the latter can not be detained but that he is "apparently" not allowed to leave the country.