When Mohamed Morsi, a leader of Egypt's Muslim Brotherhood, broke out of jail during the final days of Hosni Mubarak's presidency in 2011, he little imagined that the following year he would be president and, another year on, behind bars again.
Three years later, modern Egypt's first democratically elected leader, deposed and once more under military-backed rule, was on trial accused of various crimes including inciting violence, charges that were to bring him a life sentence and keep him in prison until his collapse in court and death, at 67, on Monday.
After decades of repression under Egyptian autocrats, the Muslim Brotherhood won election after a popular uprising toppled Mubarak in 2011, eventually propelling Morsi to power in 2012.
The US-trained engineer's victory in Egypt's first free presidential election marked a radical break with the military men who had provided every Egyptian leader since the overthrow of the monarchy in 1952.
But the euphoria that greeted the end of an era of presidents who ruled like pharaohs did not last long.
Morsi promised a moderate Islamist agenda to steer Egypt into a new democratic era where autocracy would be replaced by transparent government that respected human rights and revived the fortunes of a powerful Arab state long in decline.
The stocky, bespectacled man, born in 1951 in the dying days of the monarchy, told Egyptians he would deliver an "Egyptian renaissance with an Islamic foundation".
Instead, he alienated millions who accused him of usurping unlimited powers, imposing the Brotherhood's conservative brand of Islam and mismanaging the economy, all of which he denied.
The son of a peasant farmer was something of an accidental president, thrown into the race at the last moment by the disqualification on a technicality of millionaire businessman Khairat al-Shater, by far the group's preferred choice.
ANTAGONISING THE ARMY
Morsi was a civil engineer with a doctorate from the University of Southern California. He spoke of a simple childhood in a village in the Nile Delta province of Sharqiya, recalling how his mother taught him prayer and the Koran.
In power, Morsi made the cardinal mistake in Egyptian politics; he antagonised the military. The army chief that Morsi appointed because he was known as a religious man, General Abdel Fattah al-Sisi, eventually turned on him.
Detecting mass discontent in the streets, Sisi pushed Morsi to reach compromises with his political opponents. He refused, reaching out mainly to other Islamists.
A youth movement called Tamarud - "rebellion" in Arabic - began a petition calling for Morsi to step down. Eventually, millions took to the streets demanding that he go.
Sisi, who had been Mubarak's chief of military intelligence, appeared on television on July 3, 2013, to announce the end of Morsi's troubled one-year presidency, and plans for elections.
A severe security crackdown followed, leaving Morsi's Brotherhood, Egypt's oldest political movement, in disarray. Riot police backed by army snipers crushed Cairo protest camps calling for his reinstatement, killing hundreds.
Morsi had cited fear of judgment day as one reason for seeking the top office. He said: "We are worried that God will ask us, on the Day of Reckoning: 'What did you do when you saw that the nation was in need of sacrifice and effort?'"
Most of the Brotherhood's leaders were rounded up and put in jail. With Islamist parties largely neutered and an economy still in freefall, Sisi cemented his power, suppressing dissent and restoring Egypt to the kind of military-backed system of government that Morsi hoped to have ended for good.
Track Latest News Live on NDTV.com and get news updates from India and around the world