Hosni Mubarak, who presided over Egypt from 1981 to 2011, was on life support at a military hospital in Cairo late Tuesday night. The 84-year-old was declared clinically dead on arrival after being transferred from Tura prison, the foul facility in which so many of the critics of his regime had been incarcerated.
Mr. Mubarak came to office unexpectedly and ill prepared, although his nearly three decades in power would be the longest tenure of any Egyptian leader since Mohammed Ali in the 19th century.
He was chosen by the country's armed-forces leadership to take the place of Anwar Sadat, who had been assassinated while reviewing a military parade that celebrated the "triumph" of the 1973 war against Israel. Mr. Mubarak, who sat beside Mr. Sadat in the reviewing stand, had served as commander of the air force during that war and was rewarded with the vice-presidency in 1975, a largely ceremonial position that did not automatically make him next in line to be president.
The former fighter pilot from a rural community in the Nile Delta came to the highest office of the largest, most populous state in the Arab world not with a great vision or a dream for the country. Rather, it was the threats he faced that guided him.
First and foremost was the threat of the Islamists who had assassinated his predecessor and with whom he would wage an on-again off-again war. Second, was the political and social instability that racked the country and led him to expand Egypt's police state. And then there was the stagnant, backwater of an economy for which he sought a cure: privatization, an approach that generated wealth but led also to massive corruption.
In the uprising of 2011 and his ouster from office, it was the same three threats that proved to be his downfall.
Along the way, Mr. Mubarak had to cope with the foreign-policy legacy his predecessor had left him.
Mr. Sadat's ambitious 1979 treaty with Israel had won for Egypt peace and friends in Western capitals, but had left the country ostracized by the Arab world over which Cairo had once presided.
To his credit, Mr. Mubarak never wavered in his support for the treaty.
"His contribution to peace, as far as I'm concerned, will never be forgotten," Israeli President Shimon Peres said of Mr. Mubarak recently.
To escape Egypt's isolation in the Arab world, Mr. Mubarak turned to Iraq's ruthless dictator Saddam Hussein and became a big backer of the Iraqi's war against Iran. By the time the Iraq-Iran War was over in 1988, Egypt's name was no longer cursed by the Arab leaders.
Two years later, when Iraq invaded Kuwait, Mr. Mubarak joined forces with Kuwait's defenders and regained the political and financial support of Saudi Arabia and other Gulf states.
Egypt was back, and the headquarters of the Arab League was again on the Corniche in Cairo.
But Mr. Mubarak, who portrayed himself as a strongman, felt far from secure.
Within days of assuming the presidency, Mr. Mubarak set out to find and crush the Islamic Jihad group that had assassinated Mr. Sadat and wounded Mr. Mubarak and several others in the attack. He rounded up the usual suspects, and then some.
Later, in an attempt to reconcile with the wider Muslim opposition, he began a concerted strategy to win over the Islamic moderates while discrediting the extremists. The approach backfired as militants benefited from his moderate approach.
In 1985, on the streets of Cairo, one could hear from the preachers at several hard-line mosques scathing attacks on Coptic Christians and denunciations of decadence that marked the Sadat and Mubarak years. The only red line the Islamists could not cross, it seemed, was calling for the overthrow of the president.
By the early 1990s, the Gamaa Islamiya, another militant Islamic splinter group, was launching deadly attacks on Egypt's Copts and threatening foreign visitors. Tourism all along the Nile slowed to a trickle.
Mr. Mubarak launched a brutal suppression of the organization, killing many of its leaders who were based in the cities of Upper Egypt. The group's last violent gasp was an attack at the Temple of Hatshepsut in Luxor in 1997 that killed 62 people, most of them tourists.
Today, the Gamaa Islamiya maintains it has renounced violence and its political party, the Building and Development Party, held 13 seats in the recently dismissed parliament.
Its parent organization, the Muslim Brotherhood, all through the Mubarak years had been peace-abiding but, nevertheless, was denied legal political status. And the roundup of Islamists in the mid-1990s included many of the Brotherhood along with extreme elements.
Not surprisingly, many of the Brothers imprisoned in those years would become active in the political uprising in 2011 and be among the leaders of the Brotherhood's Freedom and Justice Party that dominated parliament until the assembly was dismissed June 15.
In the early years of the Mubarak presidency, the regime's heavy-handed approach was directed largely at the Islamists but, as other political voices strove to be heard, Egypt's police state grew and suppressed them too.
"I think the watershed moment came in 1995," said Egyptian playwright Karim Alrawi, then spokesman for the nascent Egyptian Organization for Human Rights, "when Mubarak narrowly escaped an assassination attempt at the African summit in Ethiopia."
President Mubarak and his trusted security chief Omar Suleiman returned immediately to Cairo and launched into an assault on press and other freedoms.
The Egyptian publisher and democracy activist Hisham Kassem, who was awarded the 2007 Democracy Award by the U.S. National Endowment for Democracy, recalls the struggle.
"The Saad Eddin Ibrahim case in 2000 was really the low point," Mr. Kassem said. Mr. Ibrahim, an internationally renowned sociology professor and human-rights activist was convicted of defaming Egypt's image abroad and sentenced to seven years in prison.
"They were making an example of him," Mr. Kassem said. And it worked, for a while. Groups began to retreat from their attacks on the regime.
But the outcry over the treatment of Mr. Ibrahim stirred the international community to pressure the Mubarak regime into allowing greater freedoms.
In 2004, the country's only independent newspaper, al-Masry al-Youm, began publishing and included criticism of the regime's practices in its pages. Also that year, another human-rights activist, Ayman Nour, vice-chairman of the Egyptian Organization for Human Rights, formed the Ghad Party (meaning the party of tomorrow) and became a candidate in the 2005 presidential election, the first real competition Mr. Mubarak ever faced.
While the Egyptian president would comfortably defeat Mr. Nour, the way in which he did so would prove to be the beginning of the end for Mr. Mubarak.
The election was widely regarded as rigged, with every obstacle imaginable put in the way of Mr. Nour. Even after the vote, Mr. Nour was arrested and imprisoned.
"The way he treated Ayman Nour, like the way he treated Saad Eddin Ibrahim, was petty and cowardly," Mr. Kassem said.
In those years, the Mubarak police state swelled to such a level that the budget for internal security was $1.5-billion (U.S.) , more than the entire national budget for health care.
But the genie of real popular dissent had been let out of the bottle and the Mubarak regime would never be able to put it back again.
"If Mubarak had only allowed parties like Ghad to run for office," said Mr. Kassem, "his days in office might not have ended in the horrible way they did,"
But while issues of free speech and democracy mattered greatly to Egypt's frustrated Islamists and to the secular middle class, for most Egyptians, it was the economy that mattered most.
Fully 50 per cent of Egyptians lived at or below the poverty line and past policies weren't doing much to change that. Gamal Abdel Nasser's state-dominated economy and Mr. Sadat's open-door to foreign investment failed in the face of the enormity of Egypt's poverty.
Mr. Mubarak, when he came into office, faced declining fortunes and increased debt. He felt he had no choice but to end statism, a model of development that had shaped Egyptian society for a generation.
In its place, the regime introduced structural reform –cutting public investment and subsidies, and increased privatization. To encourage new business, a previously unheard of notion, his regime eliminated most of the hundreds of obstacles that stood in the way of entrepreneurs.
In 2000, the president dispatched his son, Gamal, to lead reform within the ruling National Democratic Party and to support the private-sector initiative. A blue-ribbon council of economic advisers was struck and a plan of action produced.
GDP growth surged to more than 7 per cent, exports climbed, global bankers declared the country an up-and-comer and Egyptians abroad began to return home to be part of the boom.
But that's also where things began to sour.
The economic plan's salient points about using the boom to fund education and better the opportunities of the poor were forgotten.
Hosni and Gamal Mubarak saw to it that leading business figures were appointed to run committees in parliament – the steel baron Ahmed Ezz, for example, chaired the budget and planning committee, as well as the NDP membership committee.
The result was that friends got rewarded and wealth was concentrated in too few hands.
Small wonder that corruption was a big source of popular outrage when the Arab Spring of 2011 dawned.