In 2004, the sodomy conviction was overturned but his corruption conviction stood.
Chinese Prime Minister Li Keqiang said he was committed to maintaining good relations with Malaysia and was looking forward to cooperation from Dr Mahathir to further advance China-Malaysia's comprehensive strategic partnership.
In 2008 and 2013, he led the opposition party to considerable gains, threatening the ruling party's hold on power.
It was not clear when Anwar, who is now in hospital for treatment to his shoulder, would be freed. "The [king] has indicated he is willing to pardon Datuk Sri Anwar immediately", Mr. Mahathir said, using a Malay honorific to refer to Mr. Anwar.
Mahathir said the handover should happen soon.
Mohamad Azlan Shah, a member of Mahathir's party in the crowd, said he was "very proud".
Iranian President Hassan Rouhani has "sincerely" congratulated Mahathir Mohamad on his election as Malaysia's seventh prime minister. He added: "We will begin the. proper process of obtaining a pardon".
The royal pardon would mean he could return to politics straight away.
Mahathir and his wife Siti Hasmah Mohamad Ali were driven into the national palace in Kuala Lumpur for an audience with the king, passing hundreds of supporters waving flags and chanting the national anthem.
It might set an example to some of Malaysia's neighbours whose regimes are similarly dominated by a single party.More news: Takeaways from Google I/O 2018
More news: 'It's Time to Wrap It Up'
More news: Biologist, 104, ends life to Beethoven's Ode To Joy
"It is not just a comeback", she said.
He came out of retirement and defected to Pakatan Harapan, formed in 2015. Despite being in prison, Anwar has remained popular with opposition supporters, and it was part of Mahathir's terms of leadership that he would work to secure his release.
On Feb. 10, 2015, a Federal Court panel rejected Anwar's appeal and he was taken into custody. He is the oldest elected leader in the world.
"I was the victim in this case".
Anwar taking the premiership through an election won by Mahathir would only months ago have seemed absurd, but it now seems to be very much on the cards, with Najib, once the consummate political survivor, on the way out. "What we want is to restore the rule of law ... if the law says that Najib has done something wrong, then he will have to face the consequences".
Mahathir told CNN in January that standing in the election was a "job I have to do". In June 2017, Anwar announced he would not be the candidate.
Under Malaysia's election rules, the king picks the next prime minister.
He was first elected prime minister in 1981, serving until October 2003, when he stepped aside for his anointed successor Abdullah Ahmad Badawi.
The coalition maneuvered through several more roadblocks leading up to the most monumental electoral upset in Malaysian history.
"Today, when we asked to debate the findings, it was rejected". But many Malaysians are still upset over what they said was Mahathir's harsh treatment of political opponents and suppression of free speech.