CAIRO (AFP) - An Egyptian court on Sunday ordered a retrial for former president Hosni Mubarak after accepting an appeal against the life sentence handed him for his involvement in the deaths of protesters in 2011.

Mubarak, 84, his two sons Alaa and Gamal, his former interior minister Habib al-Adly and top security chiefs will now face a new trial, the Court of Cassation, the top appeals court, said after a very brief hearing.

The ruling was met with cries of "Long live justice!" by Mubarak supporters who held up the former strongman's picture and hugged each other in the courtroom, with dozens more outside shouting "We love you, president!"

Mubarak, his sons and Adly will remain in jail, however, as they still face separate cases.

Judge Ahmed Ali Abdelrahman told the court he had accepted the appeals by Mubarak, Adly and the prosecution, thereby cancelling all previous rulings by the Cairo criminal court. A date has still to be set for the new trial, judicial sources said.

Sunday's ruling was "expected after a flawed and disappointing trial," prominent rights group, the Egyptian Initiative for Personal Rights (EIPR) said in a statement.

Mubarak's epic fall from grace, from the dictatorial head of the Arab World's most populous nation to a defendant behind bars, was for many a promising sign that the revolution that toppled him was on the right track.

But the case against the former president verged on the farcical, with patchwork evidence and prosecution witnesses exonerating the defendants, legal experts said.

"The trial was a disappointment since the start of investigations and until the verdict. Despite popular optimism that justice was close... what we saw were superficial interrogations marred by negligence," said Hoda Nasrallah, a lawyer with EIPR. The biggest shock, she said, was that the verdict cleared the security services of any responsibility and found no one directly guilty of the killings.

EIPR urged the new court to "avoid the mistakes" of the first court hearing and called for the guarantee of a fair trial.

Sunday's ruling comes less than two weeks before the second anniversary of the start of the popular uprising that unseated Mubarak and paved the way for the election of the country's first Islamist president, Mohamed Mursi.

On June 2, Mubarak and Adly were sentenced to life in prison for failing to prevent the deaths of over 800 protesters during the 18-day uprising that began on January 25, 2011. Six security chiefs on trial in the same case were acquitted at the time.

Mubarak and his two sons, Gamal and Alaa - once the symbols of power and wealth in the country - were acquitted on corruption charges due to the expiry of a statute of limitations.

The rulings sparked nationwide outrage, with thousands taking to the streets to vent their anger that no one had been found directly guilty of killing the protesters.

Meanwhile, masked gunmen attacked protesters camped outside the presidential palace, hurling firebombs at their tents and firing birdshot in clashes that left policemen and civilians injured, a security official said on Sunday.

The gunmen threw petrol bombs overnight and set fire to the tents of protesters - opponents of Islamist President Mohamed Mursi - who have been camping out for more than a month. When police intervened the gunmen fired birdshot into the crowd, the official said. The health ministry said seven policemen, including a senior officer, and 16 civilians were injured in the clashes. A security official said two gunmen were later arrested.

The protesters have been demanding that Mursi annul an Islamist-backed constitution that has polarised the country.