Anwar Ibrahim's release from a Malaysian jail on Wednesday paves the way for him to become prime minister, a path from prison to power that has been trodden by some of the most famous leaders of the last century.
Anwar was originally jailed 20 years ago by then-premier Mahathir Mohamad, on what supporters insisted were trumped up sodomy charges.
He was imprisoned again in 2015 by Najib Razak, the man who was ousted last week in shock polls.
The now 92-year-old Mahathir, who came out of retirement to lead the revolution at the ballot box, and who now holds the top job is expected eventually to vacate the prime ministership for the younger man.
Here are five other former inmates who emerged from jail to take power:
- Nelson Mandela -
"No power on earth can stop an oppressed people determined to win their freedom," said Nelson Mandela in 1961, the year before he was convicted for leading the armed struggle for black rights in South Africa.
Mandela was sent to the notorious Robben Island penitentiary, where his 27 years behind bars left him the most recognisable face of opposition to apartheid and a rallying figure in the international campaign to isolate Pretoria's white minority government.
Released in 1990, Mandela was elected president four years later at the age of 75 in South Africa's first multiracial election.
- Aung San Suu Kyi -
The daughter of revered independence leader General Aung San, Myanmar's de facto head of state opted in her youth for a quiet family life in Oxford over continuing her father's legacy.
But when she returned to Yangon to visit her dying mother in 1988, Suu Kyi was propelled into the national spotlight during a failed national uprising against military rule. She spent 15 of the following 21 years under house arrest.
Suu Kyi's party won an emphatic victory during elections in 2015, propelling her to power, but her image as a global democracy icon has been tainted by a military crackdown on Myanmar's stateless Rohingya population that the United Nations has described as "ethnic cleansing".
- Jawaharlal Nehru -
Jawaharlal Nehru first went to jail in British-ruled India in 1921 after calling for the boycott of a tour by the Prince of Wales. He described his imprisonment as "the greatest pleasure" for allowing a showcase of his opposition to colonial rule.
He was to spend nearly a decade behind bars on various charges, often as a result of his involvement with the civil disobedience campaigns of political ally Mahatma Gandhi, who also spent years in prison.
Elected the country's first prime minister in 1947 -- a post he held until his death near 17 years later -- Nehru forged the Gandhi-Nehru family dynasty that has dominated Indian politics for most of the decades since.
- Vaclav Havel -
As a dissident playwright known in his youth for his hard-partying lifestyle, Havel's peripheral involvement in the failed Czechoslovakian uprising of 1968 prompted a lifetime of activism.
Havel was blacklisted from the theatre and had various stints in prison before rising to the presidency in the "Velvet Revolution" that toppled the country's sclerotic communist regime.
With a love of western music, one of Havel's first acts in office was to invite Frank Zappa and the Rolling Stones to perform in Prague. Both acts had been banned under the regime his government replaced.
- Michelle Bachelet -
Chile's first female president was introduced to politics by her father, a former government official who died after being tortured in detention following a 1973 military coup.
Bachelet herself was later arrested and subjected to torture for her own clandestine political activity. She went into exile in Australia and East Germany before returning to campaign for the restoration of democracy.
First elected in 2006 and serving two non-consecutive terms, Bachelet left office this year after easing restrictions on abortion and extending recognition to same sex relationships -- both contentious moves in a conservative country.