Profile: Pervez Musharraf
Pakistan's last military leader, Pervez Musharraf, dramatically returned to the country in March 2013 to compete in elections, ending four years of self-imposed exile and defying death threats.
But it seems it was a strategic mistake to do so - he was barred from standing and his All Pakistan Muslim League (APML) performed as badly as many had predicted.
He now faces trials in a series of court cases, including one in which he has been charged with treason.
In another case, he is accused of failing to provide adequate security for former Prime Minister Benazir Bhutto, which contributed to her assassination in 2007.
As president from 2001 to 2008, Pervez Musharraf was one of Pakistan's longest-serving rulers.
The military is thought to be viewing his predicament with a degree of concern, aware that his case could set a precedent in a country with a history of army rule.
- Born on 11 August 1943, Delhi, India
- Married with two children
- Joined Pakistan Military Academy in 1961
- Saw action in the 1965 war against India
- Attended Royal College of Defence Studies in the UK
- Frequently promoted, was made a general in 1998
- Self-imposed exile - mostly in the UK - between 2008 and 2013
- Since then is estimated to have earned thousands of dollars on worldwide lecture tours
Mr Musharraf, the Delhi-born son of an Urdu-speaking family that migrated to Pakistan after the partition of the Indian sub-continent in 1947, seized power in a coup in 1999.
He survived numerous assassination attempts and plots against him during his time in power.
The early part of his rule was dominated by questions of foreign policy, particularly tensions with India over Kashmir.
Then came the events of 11 September 2001 that became the defining feature of his presidency, leading to a dramatic change in Pakistan's relations with the rest of the world.
His support for US President George W Bush's "war on terror" earned him unpopularity at home. Mr Musharraf left the country in 2008 under the shadow of impeachment after losing power in elections.
During his time in self-imposed exile in London and Dubai, the former president is believed to have earned hundreds of thousands of dollars on worldwide lecture tours. But he has never made any secret that his main ambition was to return to power in his homeland.
Almost everyone agreed that would not be easy, as his struggle to find a seat in which to contest the elections showed.
By contrast with his political rivals he has negligible grassroots support.
Many of his assets in Pakistan - including cash and property - were confiscated in 2011.
Furthermore it seems increasingly clear that the army - on whose support he relied during his time in power - is reluctant to see him re-enter the political fray.
And there are at least four criminal investigations against him, as well as the treason charge.
His decision to support President Bush in 2001 inevitably meant that he would end up clashing with militants sympathetic to the Taliban and al-Qaeda.
Perhaps the most powerful manifestation of this change of direction came in July 2007, when the president ordered his security forces to storm the Red Mosque with its adjacent Islamic school in Islamabad, resulting in the deaths of more than 100 people.
Clerics and students of the mosque were accused of waging an increasingly aggressive campaign to enforce a strict interpretation of Sharia law in Pakistan's capital.
In the weeks after the mosque was seized, clashes between soldiers and Islamist militants in the country's northern tribal regions escalated and suicide bombings - a rarity in Pakistan - became much more commonplace.
His time in power was also marked by struggles with the judiciary, including an attempt to remove the chief justice and protracted disputes over his oft-stated desire to remain head of the army while simultaneously being president of Pakistan.
The president was often described as walking a tightrope as he has sought to balance pressure from the US to crack down on extremism in Pakistan and the demands from an increasingly vocal and anti-American Islamist constituency.Afghan dilemmas
Relations with India, meanwhile, worsened in 2001 after militants allegedly based in Pakistan attacked the Indian parliament.
Cases pending and assets frozen
- Faces treason charges for imposing emergency rule and arresting judges in 2007
- Accused of not doing enough to protect former PM Benazir Bhutto from being assassinated in 2007, despite allegedly being aware of Taliban plans to kill her
- Faces murder charge relating to the death of radical cleric Abdul Rashid Ghazi, during the siege of Islamabad's Red Mosque in 2007
- Accused of being indirectly responsible for the death of Nawab Akbar Khan Bugti, a Baloch nationalist leader killed in an army operation in 2006
- Assets including a farmhouse, land and accounts containing about 81m Pakistani rupees ($824,000) frozen in 2011 in relation to Bhutto allegations
By the summer of 2002 the two countries appeared to be on the brink of war with more than a million troops massed along both sides of the Line of Control that divides the disputed territory of Kashmir.
Then Afghanistan began to loom large.
Mr Musharraf was frequently accused by Nato and the Afghan government of not doing enough to stem the movement of militants sympathetic to al-Qaeda and the Taliban from Pakistan's tribal areas into Afghanistan.
At one point some in the West even questioned Mr Musharraf's usefulness in the "war on terror", strongly criticising his policy of signing local peace agreements with militants in the north-west of the country.
His constant refrain was that he was the first Pakistani leader to target al-Qaeda and Taliban fighters in Pakistan's history.
He also fought nationalists in the province of Balochistan and had to deal with increased sectarian violence between hardline Sunni and Shia groups.
Initially, he oversaw an improvement in economic growth, but in the latter part of his time in power Pakistan's finances were not considered to be especially healthy.
At the same time he faced an increasing number of challenges on the domestic front, culminating with the return of one of his main political enemies, Nawaz Sharif, to Pakistan from exile in 2007.
It marked the beginning of the end of his time in power.
The tables have now turned - Mr Sharif is back as prime minister and the man who ousted him in the coup is fighting for his political life and his freedom.