Pervez Musharraf, the last military ruler of Pakistan, who served as a key ally to the US during its "war on terror" died in exile in Dubai on Sunday at the age of 79.
The four-star general seized power in 1999 in a bloodless coup before aligning with Washington during its military intervention in neighbouring Afghanistan after the 9/11 attacks.
In nearly nine years of ruling the country, Musharraf presided over a stint of economic growth while dodging at least three Al-Qaeda assassination attempts.
But his liberal credentials failed to mask the brazen blurring of the division between the state and the army.
He famously said "the constitution is just a piece of paper to be thrown in the dustbin" and his legacy divides opinion in a nation which has witnessed at least four military coups since its founding in 1947.
In his memoir "In the Line of Fire", he quoted Napoleon and Richard Nixon as models for leadership, men both known for their tenacity -- and whose hubris contributed to their downfalls.
- 'Forceful moderate' -
Musharraf was born in Old Delhi on August 11, 1943, and his family moved to the newly created Pakistan shortly after independence.
He said he had his first brush with death falling out of a mango tree as a boy.
He joined the Pakistan Military Academy at age 18 and became a commando about five years later, rising through the ranks to reach the top when then-Prime Minister Nawaz Sharif appointed him chief of army staff in 1998.
As army chief, Musharraf orchestrated the brief, high-altitude "Kargil conflict" in Kashmir that almost took Pakistan to war with its nuclear rival India.
When he ousted Sharif in 1999 in a bloodless coup, many Pakistanis handed out sweets to celebrate the demise of a corrupt and economically disastrous administration.
Musharraf won a five-year term as president in a 2002 referendum, but reneged on promises to quit as army chief until late 2007.
When he presided over Islamabad there was said to be a popular joke: "What's the difference between Musharraf and God? God doesn't think he is Musharraf."
He aligned with the United States after the September 11, 2001 attacks, earning international praise for trying to tackle Taliban and Al-Qaeda militants.
Then-US president George W Bush called him "a strong, forceful leader (who) has become a target of those who can't stand the thought of moderation prevailing".
Musharraf's most serious challenge emerged when he tried to sack the country's chief justice in March 2007, sparking nationwide protests and months of turmoil that led him to impose a state of emergency.
After the December 2007 assassination of opposition leader Benazir Bhutto, the national mood soured even more and crushing losses suffered by his allies in 2008 elections left him isolated.
- Ignominious return -
He eventually resigned in the face of impeachment proceedings by the governing coalition and entered exile.
However, he returned to Pakistan in 2013, ostensibly to run for election and "save" the country from militancy and economic ruin.
He was met not with a hero's welcome but with apathy, ridicule, and a barrage of criminal cases.
The Taliban threatened to kill him, local media mocked his ambitions, and his plan to return to power was dashed when he was disqualified from running in an election won by Nawaz Sharif -- the very man he deposed in 1999.
Musharraf was also charged over the slaying of Bhutto and suffered the indignity of being confined to house arrest, cutting a lonely and powerless figure as the tangle of cases against him moved through the courts.
In 2016 a travel ban was lifted and Musharraf travelled to Dubai to seek medical treatment.
Three years later, he was sentenced to death in absentia for treason, related to his 2007 decision to impose emergency rule. A court later nullified the ruling.