Pervez Musharraf, the four-star general who ruled Pakistan for nearly a decade after seizing power in a bloodless coup in 1999, oversaw rapid economic growth and attempted to usher in socially liberal values in the conservative Muslim country.
Mr Musharraf, 79, died in hospital after a long illness after spending years in self-imposed exile, Pakistan media reported on Sunday. He enjoyed strong support for many years, his greatest threat al Qaeda and other militant Islamists who tried to kill him at least three times.
But his heavy-handed use of the military to quell dissent as well as his continued backing of the United States in its fight against al Qaeda and the Afghan Taliban ultimately led to his downfall.
Born in New Delhi in 1943, Mr Musharraf was four years old when his parents joined the mass exodus by Muslims to the newly created state of Pakistan. His father served in the foreign ministry, while his mother was a teacher and the family subscribed to a moderate, tolerant brand of Islam.
He joined the army at the age of 18, and went on to lead an elite commando unit before rising to become its chief. He took power by ousting the then prime minister, Nawaz Sharif, who had tried to sack him for greenlighting an operation to invade areas of Jammu and Kashmir, bringing Pakistan and India to the brink of war.
In his early years in government, Mr Musharraf won plaudits internationally for his reformist efforts, pushing through legislation to protect the rights of women and allowing private news channels to operate for the first time.
His penchant for cigars and imported whisky and his calls for Muslims to adopt a lifestyle of "enlightened moderation" increased his appeal in the West in the aftermath of the Sept. 11, 2001 attacks in the United States.
He became one of Washington's most important allies after the attacks, allowing US forces to operate armed drones from secret bases on Pakistani soil that killed thousands and ordering domestic troops into the country's lawless tribal areas along the Afghanistan frontier for the first time Pakistan's history.
That helped legitimise his rule overseas but also helped plunge Pakistan into a bloody war against local extremist militant groups.
In a 2006 memoir, he took credit for saving Pakistan from American wrath saying the country had been warned it needed to be "prepared to be bombed back to the Stone Age" if it did not ally itself with Washington.
Mr Musharraf also successfully lobbied then-President George W Bush to pour money into the Pakistani military. Still, the army's allegiances were never unambiguous: its powerful intelligence services cut deals with the Taliban and al Qaeda, and bolstered an insurgency fighting US troops in Afghanistan.
In other areas of foreign policy, Musharraf attempted to normalise relations between New Delhi and Islamabad.
At a regional summit in 2002, less than three years after launching the military operation against India, Musharraf shocked the world when, after finishing a speech, he suddenly moved towards Indian Prime Minister Atal Bihari Vajpayee to shake hands and offered to talk peace.
Analysts say the issue of Kashmir - which remains the most potent point of contention between India and Pakistan - was close to being solved during the Musharraf era. But the peace process was derailed soon after his rule.
Under Musharraf, foreign investment flourished and Pakistan saw annual economic growth of as much as 7.5 per cent - which remains the highest level in nearly three decades, according to World Bank data.
The later years of his presidency were, howeverm overshadowed, by his increasingly authoritarian rule. In 2006, Mr Musharraf ordered military action that killed a tribal head from the province Balochistan, laying the foundations of an armed insurgency that rages to this day.
The next year, more than a hundred students calling for the imposition of Sharia law were killed after Mr Musharraf shunned negotiations and ordered troops to storm a mosque in Islamabad. That led to the birth of a new militant group, Tehreek-e-Taliban Pakistan, which has since killed tens of thousands in suicide bombings and brazen assaults.
Later in 2007, a suicide attack that assassinated opposition leader Benazir Bhutto, triggered waves of violence. His efforts to strong arm the judiciary also led to protests and a besieged Musharraf postponed elections and declared a state of emergency.
In 2008, the country's first democratic elections in 11 years were held. Musharraf's party lost and facing impeachment by parliament he resigned the presidency and fled to London.
He returned to Pakistan in 2013 to run for a seat in parliament but was immediately disqualified. He was allowed to leave for Dubai in 2016.
In 2019, a court sentenced him to death in absentia for the 2007 imposition of emergency rule but the verdict was later overturned.
Track Latest News Live on NDTV.com and get news updates from India and around the world