An Egyptian court has dropped its case against former president Hosni Mubarak over the killing of 239 protesters in the 2011 revolt that ended his three-decade rule.

Mubarak, 86, was sentenced to life in prison in 2012 for conspiring to murder the demonstrators, sowing chaos and creating a security vacuum during the 18-day revolt, but an appeals court ordered a retrial.

His supporters erupted into celebration when the verdicts of that retrial - which also cleared his former interior minister Habib al-Adly and six aides - were read out.

Those supporters outside court, carrying pictures of the former air force officer who loomed so large over the most populous Arab nation for three decades, far outnumbered families of protesters who died in the Tahrir Square revolt.

The judge said criminal charges should never have been brought against Mubarak in the case. The decision can be appealed, however, and the former leader was not freed as he is serving a three-year jail term for embezzlement.

Many Egyptians who lived through Mubarak's rule view it as a period of autocracy and crony capitalism, and considered it a victory to see him behind bars.

His overthrow led to Egypt's first free election but the winner, Mohamed Mursi, was ousted last year by the army. The release of some Mubarak-era figures since then and a series of laws curtailing political freedoms had already raised fears among activists that the old leadership was regaining influence.

"This is a political verdict. The judiciary has been procrastinating for four years so they could clear him after hope had been lost," said the father of 19-year-old Ahmed Khaleefa, who was killed in 2011, outside the court. "The verdict hit us like bullets. I consider that my son Ahmed died today."

Hundredsof people died when security forces clashed with protesters in the weeks before Mubarak was forced from power in February 2011.

Othman al-Hefnawy, a lawyer representing some of the families of the protesters who died, said the verdict left open the question of who was responsible for 239 deaths.

The court also cleared Mubarak and a former oil minister of graft charges related to gas exports to Israel. In a separate corruption case, charges were dropped against Mubarak and his sons Alaa and Gamal, with Judge Mahmoud Kamel al-Rashidi saying too much time had elapsed since the alleged crime took place for the court to rule on the matter.

State television showed Gamal and Alaa kissing their father's forehead after the ruling was read. Gamal also hugged former interior minister Adly. Both Mubarak's sons and Adly will remain in jail serving other sentences.

The political demise of Mursi and his Muslim Brotherhood means voices more sympathetic to Mubarak and the military have since been heard. In August, Mubarak used a rare court testimony to protest his innocence, saying he would go to his grave with a clear conscience and that history would vindicate him.

He will remain in an army hospital, where he is serving the three-year sentence he was handed in May.