An upbeat and alert-looking Hosni Mubarak waved to his supporters after he was wheeled into a Cairo courtroom on Saturday for the first session of his retrial on charges of complicity in the killing of demonstrators during the 2011 revolt that led to his ouster.

The procedural session quickly ended when the judge recused himself, referring the case to an appeals court to choose a replacement.

Mubarak sat upright on a hospital gurney inside a defendants' cage of iron bars and wire mesh. His two sons Alaa and Gamal and his former interior minister Habib al-Adly, currently held in prison for separate cases, were also in the courtroom cage alongside him.

Mubarak is the first Arab president to serve a prison sentence. The 84-year-old ousted Egyptian leader, wearing brown-tinted glasses, had not been seen in public since his initial conviction in June 2012. Unconfirmed reports had emerged several times in the past year suggesting that he was on the brink of death.

He was airlifted by a military helicopter to the court from a Cairo hospital. His two sons and el-Adly were driven from Tora prison.

si-hosni-mubarak-court-300-ap-04278626

Hosni Mubarak, 84, centre, appears in court behind bars along with his sons, Alaa Mubarak, right, and Gamal Mubarak, unseen, during Saturday's hearing. (Ahmed Abd El Latef/El Shorouk Newspaper/Associated Press)

Judge Mostafa Hassan recused himself on Saturday from the trial, but did not specify the conflict of interest behind this decision.

As he took the bench, some lawyers shouted to demand that he step down from the case.

"Sit until you hear what the court's decision is," the judge responded.

Immediately after he announced that the case would be sent to an appeals court, some lawyers began chanting, "The people demand the execution of the ousted president!"

Local media reports had suggested Hassan might transfer the case to another judge. He sparked an uproar in October among Egyptian political activists when he ordered the acquittals of 25 Mubarak loyalists who had been accused of organizing a deadly attack during the 18-day revolt in which assailants on horses and camels stormed downtown Cairo's Tahrir Square.

Mubarak and el-Adly's retrial was granted by an appeals court that overturned their life sentences in January. The presiding judge of that first trial said the prosecution's case lacked concrete evidence and failed to prove the protesters were killed by the police.

If convicted again, the life sentence passed against Mubarak and al-Adly would be upheld. They could also have their sentence reduced or even be acquitted. It is considered unlikely that they would draw a heavier sentence, like the death penalty.

His two sons and six police generals are also being retried after prosecutors filed an appeal against their acquittals. The sons face corruption charges. Five of the police generals face the same charges as Mubarak while the sixth is accused of gross negligence.

The scene outside of the courthouse highlighted the sharp difference in Egypt's political atmosphere compared to the start of Mubarak's first trial in August 2011.

Hundreds flocked to the courtroom for his first trial, while Egyptians and others in the region were glued to their televisions in near-disbelief at seeing the former autocrat in a courtroom cage, a symbol to many of the people's triumph over dictatorship.

The retrial drew only a few dozen Mubarak opponents and supporters, who briefly threw stones at each other before police intervened.

More than two years after his ouster, Egyptians are reeling from a myriad of problems that include fuel shortages, growing unemployment and political polarization that has at times led to deadly street battles between different factions.

Some have even grown nostalgic for the Mubarak years, when tourism and other vital economic pillars fared better. Elsewhere, the Arab Spring has turned into a war in Syria that has claimed more than 70,000 lives and sent hundreds of thousands of people fleeing to neighboring countries.

The former president, who ruled Egypt for 29 years, has remained in custody since his conviction, spending some time in a prison hospital before being transferred to a military one on grounds he needed better medical care.

A high-level inquiry into the deaths of the nearly 900 protesters killed in the uprising, parts of which were released exclusively to The Associated Press last month, could weigh heavily in the retrial.

It found that police were behind nearly all the killings, using snipers on rooftops overlooking Tahrir Square to shoot into huge crowds.

The inquiry determined that such deadly force could only have been authorized by al-Adly with the ousted president's full knowledge. The report could play heavily in the retrial.

The fact-finding commission was created by Mubarak's successor Mohammed Morsi after his election win last summer and campaign promises of brining former officials to justice.

Morsi's Muslim Brotherhood supporters, though, have spoken out in support of so-called reconciliation talks with former officials, many of whom have been acquitted and released from prison in recent months.

Additionally, nearly 100 police officers have faced trial over the killing of protests during the revolt, and all but two were acquitted.