Egypt’s top appeals court has acquitted former President Hosni Mubarak of conspiring in the killing of hundreds of protesters during the 2011 uprising.

Mr Mubarak was sentenced to life in prison after being convicted in 2012, but the case was retried twice.

Thursday’s Court of Cassation ruling is final, which could mean the ailing 88 year old is freed from detention.

He has been confined to a military hospital despite having completed a three-year sentence for embezzlement.

A judge decreed in May 2015 that Mr Mubarak could be released from detention.

However, the government of President Abdul Fattah al-Sisi was reportedly reluctant to free him because of the public backlash that might accompany such a move.

Mr Sisi served as Mr Mubarak’s military intelligence chief and led the military’s overthrow of his democratically elected successor, Mohammed Morsi, in 2013.

In all, more than 800 people are believed to have been killed as security forces sought to stop protests in Cairo, Alexandria, Suez and other cities around Egypt during the 18-day uprising that forced Mr Mubarak to resign after 30 years in power.

He denied ordering the killing of protesters and insisted that history would judge him as a patriot who served his country selflessly.

Mr Mubarak’s first retrial was ordered in 2013. A judge dropped the charge altogether the following year, but the Court of Cassation ordered a second retrial.

Former Interior Minister Habib al-Adly and four of his aides were also acquitted of the same charge on Thursday.

The Court of Cassation also rejected demands by lawyers of the protesters’ families to pursue civil suits against Mr Mubarak.