Jailed former opposition leader Anwar Ibrahim greets supporters after his released from the Cheras Hospital Rehabilitation in Kuala Lumpur on May 16, 2018.
(CNN) - Anwar Ibrahim, a former Malaysian Deputy Prime Minister, has walked free after being granted a pardon for sodomy by the country's king, according to Anwar's son-in-law Mohamad Khairul.
The pardon potentially paves the way for him to succeed the country's elderly new leader Mahathir Mohamad, who was the surprise victor over former Prime Minister Najib Razak in last week's parliamentary election.
Surrounded by media and supporters, Anwar walked out of a hospital Wednesday where he was recovering from surgery. Anwar had been serving a five-year prison sentence for sodomy charges he says were politically motivated. Until his early release, he had been scheduled to be freed in early June.
The politician, a voice for reform in Malaysia and once a leading light in the party that ruled Malaysia until last week's election, was jailed in 2015. It was the second time he had been convicted of a sodomy offense.
Mahathir, 92, and Anwar, 70, had put aside a longstanding rivalry to fight together to defeat Najib. Anwar's wife, Wan Azizah Wan Ismail, endorsed Mahathir and served as his deputy in the coalition to oust Najib.
Mahathir and Anwar are a political odd couple who have "hated each other politically" for two decades, James Chin, Director of the Asia Institute at the University of Tasmania, told CNN ahead of the election last week.
However, the Malaysian public saw the two politicians' "rapprochement as something very good," Chin said, and together they toppled Najib and broke the ruling coalition's 60-year grip on the country.
Anwar made his name as a student activist in various Muslim youth groups in Kuala Lumpur in the late 1960s, as the country reeled from the protracted Communist insurgency of the Malayan Emergency.
Arrested in 1974 in student protests against rural poverty, Anwar was sentenced to 20 months in jail. Despite his firebrand reputation, he later confounded liberal supporters in 1982 by joining the conservative United Malays National Organization (UMNO) led by Mahathir.
The freed politician was the heir apparent to then-premier Mahathir until 1998, when he was sacked and charged for corruption and sodomy. He was found guilty the following year, a ruling that led to mass street demonstrations.
The sodomy conviction was overturned, but the corruption verdict was never lifted, barring him from running for political post until a decade later.
In 2008, once his ban on political participation was lifted, he was hit with further sodomy charges.
Following an appeal of the acquittal of those charges he was convicted again and jailed in 2015. Human rights groups were highly critical when the conviction was upheld, calling it politically motivated -- a claim the government denied.