Hosni Mubarak, Egypt’s president for almost 30 years who stepped down after a popular revolution in 2011, has died. He was 91.

Mubarak served as Egypt’s fourth president starting in 1981 until his ouster in what became known as the Arab Spring revolution.

He was jailed for years after the uprising, but was freed in 2017 after being acquitted of most charges.

Mubarak died weeks after undergoing surgery.

Aljazeera reports that his brother-in-law, General Mounir Thabet, told AFP news agency, he passed away at Cairo’s Galaa military hospital.

Throughout his rule, he was a stalwart US ally, a bullwark against armed groups, and guardian of Egypt’s peace with Israel. But to the tens of thousands of young Egyptians who rallied for 18 days of unprecedented street protests in Cairo’s central Tahrir Square and elsewhere in 2011, Mubarak was a relic, a latter-day pharaoh.

Mubarak was born in a rural village in the Nile Delta in 1928. He left behind a complicated legacy as his rule was partly characterised by corruption, police brutality, political repression, and entrenched economic problems.

He 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 Yom Kippur War.

His harsh stance on security enabled him to maintain the peace treaty with Israel.

Under his rule, Egypt remained a key United States ally in the region – receiving $1.3bn a year in US military aid by 2011.

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