An Egyptian court on Saturday sentenced deposed Islamist president Mohamed Morsi and more than 100 other people to death for their role in a mass jailbreak during the 2011 uprising.
Hours after the ruling, gunmen shot dead two judges, a prosecutor and their driver in the strife-torn Sinai Peninsula, in the first such attack on the judiciary in the region.
Morsi, sitting in a caged dock in the blue uniform of convicts after already been sentenced to 20 years for inciting violence, raised his fists defiantly when the verdict was read.
Judge Shabaan El-Shamy handed down the same sentence to more than 100 other defendants including Muslim Brotherhood leader Mohamed Badei, already sentenced to death in another trial, and his deputy Khairat al-Shater.
Morsi, elected president in 2012 as the Brotherhood's compromise candidate after Shater was disqualified, ruled for only a year before mass protests spurred the military to overthrow him in July 2013.
He was among dozens of Islamist leaders detained during a crackdown that left hundreds of Morsi supporters dead.
Many of those sentenced on Saturday were tried in absentia, including prominent Qatar-based Islamic cleric Yusuf al-Qaradawi.
The court will pronounce its final decision on June 2, since under Egyptian law, death sentences are referred to the mufti, the government's interpreter of Islamic law, who plays an advisory role.
Defendants can still appeal even after the mufti's recommendation.
"If he (Morsi) decides that we appeal against the verdict, then we will. If he continues to not recognise this court, then we won't appeal," said defence lawyer Abdel Moneim Abdel Maksoud.
- 'Deplorable justice system' -
Amnesty International lashed out at Saturday's verdict, saying it reflected "the deplorable state of the country's criminal justice system".
"The death penalty has become the favourite tool for the Egyptian authorities to purge the political opposition," the London-based rights watchdog said.
Turkish President Recep Tayyip Erdogan condemned the death sentence, saying the country was "turning back into ancient Egypt", referring to Pharaonic rule that ended more than two millennia ago.
After Saturday's verdict was pronounced, gunmen in the Sinai shot dead two judges and a prosecutor travelling to El-Arish for a court hearing.
Their driver was also killed and another prosecutor was wounded, health ministry spokesman Hossam Abdel Ghaffar told AFP.
Some of Morsi's fellow defendants included jihadists from Sinai, where militants often attack security forces.
Signup to our newsletter and follow us on Facebook and Twitter!
Morsi, 64, has yet to be sentenced in the first of two trials that concluded on Saturday, in which the death penalty was given to 16 other defendants convicted of espionage.
They were all found guilty of colluding with foreign powers, the Palestinian Islamist group Hamas and Iran to destabilise Egypt.
The court will pronounce the verdicts for Morsi and another 18 defendants in that trial on June 2.
The court then delivered its verdict in the case in which Morsi and 128 defendants were accused of plotting jailbreaks and attacks on police during the uprising that overthrew president Hosni Mubarak in 2011.
Morsi and more than 100 of them were sentenced to death.
Many of the defendants are Palestinians alleged to have worked with Hamas in neighbouring Gaza. They were tried in absentia, as was a Lebanese Hezbollah commander.
They were alleged to have colluded with Morsi's Muslim Brotherhood to carry out attacks in Egypt in what prosecutors allege was a vast conspiracy.
- 'Verdict against Palestinians' -
Condemning the verdict, Hamas said that some of its members mentioned in the proceedings were already dead before the 2011 uprising, while some are in Israeli prisons.
The verdict "is a crime against the Palestinian people and their courageous resistance, and is a systematic demonisation campaign targeting Hamas", spokesman Fawzy Barhum told AFP.
Morsi and other former opposition members have now been condemned for violence during the anti-Mubarak uprising, while Mubarak himself has been cleared of charges over the deaths of protesters during the 18-day revolt that toppled him.
Morsi was in prison when the anti-Mubarak uprising erupted on January 25 2011, having been rounded up with other Brotherhood leaders a few days earlier.
On January 28, protesters fuelled by police abuses torched police stations across Egypt, allowing thousands of prisoners to escape when the force all but collapsed.
Since Morsi's overthrow, the police has largely been rehabilitated in public eyes, with officials and loyal media blaming the Brotherhood and foreigners for the violence of the anti-Mubarak uprising.
The army chief who overthrew Morsi, Abdel Fattah al-Sisi, was himself elected president last year.
He has pledged to eradicate the Brotherhood, once Egypt's largest political movement.