His time in office was marked by frequent oppression and human rights abuses, especially as it drew to an end.
However, he also promoted social liberalism under what he termed an "enlightened moderation program," which envisaged a society based on a nonfundamentalist interpretation of Islam. On the economic front, his presidency coincided with a rise in overall gross domestic product by around 50%.
Born in New Delhi in 1943, four years before Pakistan and India gained their independence from British colonial rule in August 1947, Musharraf lived and went to school in Turkey as a child before returning to Pakistan in 1956.
He was commissioned as a trainee officer in the Pakistani army in 1961. Later, the young Musharraf rapidly climbed the ranks of the military and fought in two wars against neighboring India in 1965 and 1971.
Took power in bloodless coup
Musharraf was promoted to four-star general by then-Prime Minister Nawaz Sharif in 1998, making him the serving chief of the army staff. He was in charge of the Kargil infiltration that led to a war between India and Pakistan in 1999.
It was also in this capacity as leader of Pakistan's armed forces that he staged a bloodless coup against Sharif in 1999, after Sharif tried to remove him from his position after months of contention.
This enabled Musharraf to become president of the country in 2001.
As a military dictator trying to assist the United States in its "war on terror," especially in Afghanistan, and fighting an ever-increasing amount of criticism at home because of his policies, Musharraf survived at least three attempts on his life during his seven-year rule. These were attacks planned by Pakistan's Taliban militants.
The biggest failed attempt to assassinate Musharraf was on December 14, 2003, when a bomb attack targeted his high-security convoy as it was crossing a bridge in Rawalpindi.
Attacks from local Taliban groups began to increase in Pakistan during Musharraf's rule. The special forces' operation against religious extremists holed up in the Red Mosque in Islamabad was also carried out in 2007. Musharraf was hugely criticized for the incident, in which over 150 people died.
Benazir Bhutto, Pakistan's former prime minister and leader of the opposition's Pakistan People's Party, was also murdered in 2007 at the end of an election rally in Rawalpindi during Musharraf's rule.
Musharraf had always said that he wanted to change Pakistan, to make it a peaceful, developed and prosperous nation. And while in power, he did what he felt he had to, though not always with unanimous support. Pakistan did change a lot — during his rule and also afterward. But it wasn't in the way he had intended, and perhaps not the way the majority of the over 220 million Pakistanis wanted, either.
Rivals make impeachment plans
As president, Musharraf also had huge differences with the judiciary. He suspended Chief Justice Iftikhar Chaudhry from office after the Pakistan Supreme Court had wanted to examine the legality of Musharraf's reelection as president in October 2007.
Musharraf's political career took a turn for the worse on August 7, 2008, when his former Prime Minister Sharif and Bhutto's widower, Asif Ali Zardari, announced a plan to impeach him.
Eleven days after that, Musharraf announced his resignation as president and was promised permission to leave the country, allowing him to emigrate to London.
When Musharraf returned to Pakistan at the end of March 2013, he did so as the head of his new political party, the All Pakistan Muslim League, and with a plan: to return to power through public support.
The crowd of people welcoming him back to Karachi was, however, smaller than he had anticipated.
Upon his return, Musharraf said he wanted to free Pakistan from terrorism and that he was risking his life: the Taliban had threatened to kill him upon arrival.
In the end, however, he was disqualified from taking part in that year's general election after arrest warrants were issued for him and former Prime Minister Shaukat Aziz over their alleged involvement in the killings of Pakistani politician Nawab Akbar Bugti and of Benazir Bhutto.
Musharraf moved to Dubai in the United Arab Emirates in 2016, leading to his being declared an "absconder" in the Bhutto assassination case. He was then sentenced to death in absentia on the treason charges, though that sentence was later lifted by the Lahore High Court.
He died in Dubai on February 5 after suffering from a prolonged case of amyloidosis.