An Egyptian court on Tuesday confirmed a death sentence handed to ousted Islamist president Mohammed Morsi over a mass prison break during the 2011 uprising that eventually brought him to power.

Morsi, Egypt's first freely elected president, was in the courtroom in a glass-covered cage, with mesh wires over it. He listened to the verdict with a slight smile but did not say anything.

The ruling was read out by Judge Shaaban al-Shami after he consulted with Egypt's Mufti, a religious authority affiliated with the judiciary, as required by law in cases involving capital punishment.

"The court panel has unanimously agreed that there is no room for leniency or mercy for the defendants," al-Shami, who presides over a panel of three, said before confirming the death sentence.

The Mufti's opinions are not binding, and the ruling will automatically be referred to Egypt's highest appeals court.

The judge also confirmed death sentences for five other jailed leading members of Morsi's Muslim Brotherhood, including Mohammed Badie, the group's leader, and Saad el-Katatni, the head of its short-lived political party.

Al-Shami said the defendants conspired and attempted to kill police officers when they broke into three of Egypt's prisons, enabling some 20,000 inmates to flee, causing chaos in Egypt and breaching its borders with the Gaza Strip. He said they did so with the help of foreign militants from the Palestinian Hamas movement, Lebanon's Hezbollah and Sinai militants.

Another 21 imprisoned defendants received life sentences in the case, which in Egypt is equivalent to 25 years in prison. Another 93 defendants were tried in absentia and sentenced to death.

Now Morsi will change his blue prison outfit to an orange one in future cases. Morsi is already serving a 20-year sentence for his part in the killings in 2012 of protesters outside his palace when he was still president.

Morsi was forced out of office in July 2013 by the military amid massive protests demanding his resignation. He has been detained since then, and his Muslim Brotherhood has been labelled a terrorist organization.

Earlier Tuesday, the same judge sentenced Morsi to life in prison over charges of conspiring with foreign groups, including the Palestinian militant group Hamas. That sentence can also be appealed.

Al-Shami confirmed death sentences against 16 other Islamists, including three jailed senior Brotherhood members. The other 13 were tried in absentia. Morsi was among 17 defendants sentenced to life in prison in that case.