On October 6, 1981, during a parade commemorating the 1973 October War, soldiers dismounted from army trucks and assassinated Egyptian President Anwar Sadat in a hail of gunfire and grenade explosions. His vice president, Hosni Mubarak, who was standing beside him and was injured in the attack, assumed the presidency a week later.

Mubarak was president for almost 30 years, becoming Egypt's longest-serving ruler since Muhammad Ali Pasha - the Ottoman-era figure considered the founder of the modern Egyptian state.

The foundations of Mubarak's presidency cracked in their later years and finally crumbled during an 18-day uprising that began on January 25, 2011.

Mubarak, who died on Tuesday at the age of 91, left behind a complicated legacy. His rule was partly characterised by corruption, police brutality, political repression, and entrenched economic problems. Yet, in the years of turmoil that followed his removal, some became nostalgic for the stability, certainties, and the large numbers of tourists that Mubarak's rule ostensibly ensured.

Military, political rise

Mubarak was born in a rural village in the Nile Delta in 1928. After completing his studies at the Egyptian Military Academy following high school, Mubarak joined the Egyptian air force in 1949, graduating as a pilot the following year. He rose through the ranks to become the commander-in-chief of the Egyptian air force in 1972.

Mubarak became a national hero the following year, with reports that the Egyptian air force dealt a substantial blow to Israeli forces in Sinai during the October War. Sadat made Mubarak vice president in 1975.

Former Egyptian President Anwar al-Sadat leans in to speak with then-Vice President Hosni Mubarak as they travel from Cairo to Alexandria on board the Egyptian presidential helicopter in 1977 [Getty Images]

Sadat was killed by Islamist members of the military who were angered by the 1978 Camp David Accords with Israel. Mubarak responded to the assassination by imposing emergency law, which gave him sweeping powers - an action he never revoked. He cracked down hard on Islamist groups, and thousands were arrested. Mubarak was targeted in several assassination attempts.

Mubarak's harsh stance on security enabled him to maintain the peace treaty with Israel. Egypt remained a key US ally in the region - receiving $1.3bn a year in US military aid by 2011. US embassy cables leaked by WikiLeaks described Mubarak as "a tried and true realist, innately cautious and conservative, [who] has little time for idealistic goals".

Some argue that Egypt's regional influence diminished during Mubarak's presidency as other Arab nations came to the fore and he focused largely on domestic affairs.

Part of Mubarak's domestic focus involved extending the repressive security apparatus built under former President Gamal Abdel Nasser and maintained under Sadat. Opposition forces of any hue were spied on and subject to harassment and imprisonment. Police brutality and torture in custody were "routine and pervasive". Elections were characterised by widespread rigging and fraud in favour of Mubarak's National Democratic Party. The media was under tight control and censorship.

Throughout Mubarak's rule, Islamist ideas gained more traction. In an attempt to assuage widespread Islamist demands, Mubarak permitted the Muslim Brotherhood a degree of freedom and their grassroots social services and piety fostered popularity. Although the Brotherhood was technically outlawed, their members were often allowed to run for parliament as independents.

John R Bradley, in his book titled Inside Egypt, argued that the Brotherhood under Mubarak was a "crucial pillar of the establishment rather than its nemesis", and that the relative mollification of the Brotherhood came at the expense of secular opposition groups, which were hugely repressed.

Egypt underwent a process of relative economic liberalisation and privatisation under Mubarak. In the later years of Mubarak's rule, many of the macroeconomic indicators appeared healthy: economic growth was averaging between five to 6 percent, there was a stable exchange rate, and Egypt enjoyed healthy financial ratings. 2010 was Egypt's peak year for foreign tourists.

Yet, these broad-brush indicators masked a range of chronic social problems that included high inflation, unemployment in the double digits, and severe, entrenched poverty. Critics argued that the economic reforms enriched an elite group of businessmen and military officials, leading to widening inequality and corruption.

Protesters burn a picture of Mubarak as they shout anti-government slogans during a demonstration in Cairo January 29, 2011 [File: Asmaa Waguih/Reuters]

Revolution

From 2006 onwards, worker strikes became a more common phenomenon. As Egypt's population nearly doubled under Mubarak's presidency, a burgeoning demographic of young people became increasingly frustrated at a lack of opportunities.

"The average citizen heard the policies that were announced by the government, and [found] the reality on the ground completely different", professor of economics at the American University in Cairo (AUC), Tarek Selim, said in September 2013. "This actually ignited the January 25 revolution."

On January 25, 2011 - an annual holiday commemorating Egypt's police - protesters took to the streets, calling for the fall of Mubarak's government under the slogan: "Bread, freedom and social justice".

Mubarak made a speech, which he labelled "A father's dialogue with his sons and daughters", calling for an end to protests and promising limited reforms. On the ground, thugs and the security forces attacked the demonstrations but the protesters could not be shaken from the streets. Mubarak stepped down as president on February 11, 2011.

Many protesters, initially giddy with joy and disbelief, quickly realised that although they had toppled Mubarak, the system he had headed largely remained intact. The years following Mubarak's overthrow were turbulent as activists protested against direct military rule, and later, against the Brotherhood-affiliated Mohamed Morsi, who was elected as president in June 2012 and overthrown one year later by military chief, Abdel Fattah el-Sisi, who was head of military intelligence under Mubarak.

Many who experienced the chaos of the uprisings decided they preferred the order of a strongman ruler. El-Sisi was elected president in May 2014.

Trial, prison, release

During this time, Mubarak, his family members and his officials faced a series of charges in the courts. Mubarak was first detained in April 2011. In the court sessions, he appeared a frail figure: typically wearing sunglasses, lying on a gurney, his jaw set. A life sentence in 2012, on charges relating to the killing of hundreds of protesters, was overturned on appeal and a retrial was ordered.

Insights into his personal corruption emerged. In May 2014, Mubarak and his sons Gamal and Alaa were found guilty of embezzling $17.6m of state funds. Mubarak was sentenced to three years imprisonment and his sons to four.

A file photo dated 13 April 2013 shows Gamal Mubarak, left, and brother Alaa Mubarak, right, with their father former Egyptian President Hosni Mubarak in a cage inside the court during his trial at the Police Academy in Cairo [File: Khaled Elfiqi/EPA]

In November 2014, charges of inciting the killings and further corruption claims against Mubarak were dismissed by a judge on a legal technicality. The reaction to the verdict was largely muted, although over a thousand anti-Mubarak protesters gathered near Tahrir Square. The protesters being swiftly dispersed arguably demonstrated the endurance of the repressive and increasingly authoritarian institutions that Mubarak had extended.

"What appears [to be] happening in Egypt is the reproduction of the Mubarak regime - naturally without Mubarak, but with a central role [of] the state as the main feature of the process of reproduction," Walid Kazziha, professor of political science at AUC, said after the Mubarak verdict.

Some claim that Mubarak's role was best understood as the governing figurehead of the real source of power: the military. When forceful protests erupted against him, some argued that the military sacrificed Mubarak, allowing military rule, hidden behind the scenes, to survive.

In death, Nasser and Sadat continue to haunt Egypt - their images remain publicly prevalent. Mubarak lacked the charisma and popularity of those leaders, but he far surpassed them in longevity.

Some activists and analysts claim Mubarak will continue to be the spectral symbol of a frustrated revolution that not only attempted to topple him, but aimed for wider systemic reform, a struggle that continued years after his removal. The security institutions and systems that Mubarak maintained - and which sacrificed him - have endured.

Mubarak is survived by his wife, Suzanne, and his sons, Gamal and Alaa.