Updated

An appeals court on Sunday overturned Hosni Mubarak's life sentence and ordered a retrial of the ousted Egyptian president for failing to prevent the killing of hundreds of protesters during the uprising that toppled his regime.

The ruling, read out by judge Ahmed Ali Abdel-Rahman, dredged back up the highly divisive issue of justice for the former leader — and his top security officers — in a country that remains mired in political turmoil and economic malaise nearly two years after Mubarak's fall.

Mubarak, who is currently being held in a military hospital, will not walk free with Sunday's court decision— he will remain in custody while under investigation on charges in an unrelated case. The 84-year-old ex-president was reported last year to have been close to death, but the current state of his health is unknown.

A small crowd of Mubarak loyalists in the courtroom erupted with applause and cheers after the ruling was read out. Holding portraits of the former president aloft, they broke into chants of "Long live justice." Another jubilant crowd later gathered outside the Nile-side hospital where Mubarak is being held in the Cairo district of Maadi, where they passed out candies to pedestrians and motorists.

The court did not provide the reasoning for its decision, but the grounds for granting the appeal were expected to be released later. No date has been set for the retrial.

The decision to grant the appeal, however, had been widely expected. When Mubarak was convicted and sentenced to life in June, that trial's presiding judge criticized the prosecution's case, saying it lacked concrete evidence and that nothing in what was presented to the court proved that the protesters were killed by the police.

Mubarak's defense lawyers had argued that the former president did not know of the killings or realize the extent of the street protests. But an Egyptian fact-finding mission recently determined that he watched the uprising against him unfold through a live TV feed at his palace.

The mission's report could hold both political opportunities and dangers for Mubarak's successor, President Mohammed Morsi of the fundamentalist Muslim Brotherhood. A new Mubarak trial would be popular, since many Egyptians were angered he was convicted for failing to stop the killings, rather than ordering the crackdown that killed nearly 900 people.

But the report also implicates the military and security officials in the protesters' deaths. Any move to prosecute them could spark a backlash from the powerful police and others who still hold positions under Morsi's Islamist government at a time when the nation's new leader is struggling to assert his authority over a nation reeling from political upheaval.

The judge also ordered a retrial of Mubarak's former security chief, Habib el-Adly, convicted and sentenced to life in prison on the same charges.

He also ordered the retrial of six of el-Adly's top aides who were acquitted in the same trial. Five of them were found not guilty of involvement in the killing of the protesters, while one was acquitted of "gross negligence." No date was set for their retrial either.

It also granted the prosecution's request to overturn not-guilty verdicts on Mubarak, his two sons and an associate of the former president, Hussein Salem, on corruption charges. Salem was tried in absentia and remains at large to this day.

The six top police commanders held key positions at the Interior Ministry, which was led by el-Adly and which is in charge of the security forces. Their acquittal surprised many Egyptians who are still demanding retribution for the nearly 900 protesters killed during the 18-day uprising that culminated with Mubarak's ouster on Feb 11, 2011.

The prosecutors in the Mubarak trial complained that security agencies and the nation's top intelligence organization had not cooperated with their investigation, leaving them with little incriminating evidence against the defendants. During the trial, prosecutors focused their argument on the political responsibility of Mubarak and el-Adly.

Sunday's ruling came one day after a prosecutor placed a new detention order on Mubarak over gifts worth millions of Egyptian pounds he and other regime officials allegedly received from Egypt's top newspaper, Al-Ahram, as a show of loyalty while he was in power.

The public funds prosecutor ordered Mubarak held for 15 days pending the completion of the investigation. Mubarak, 84, was moved to a Cairo military hospital last month after slipping inside a prison bathroom and injuring himself.

Mubarak's sons, one-time heir apparent Gamal and businessman Alaa, are in prison while on being tried for alleged insider trading and using their influence to buy state land at a fraction of its market price.