An Egyptian court sentenced deposed Islamist president Mohammed Morsi and more than 100 others to death on Saturday for their role in a mass jailbreak during the 2011 uprising.
Hours after the ruling, gunmen shot dead three judges in the strife-torn Sinai Peninsula.
Morsi, sitting in a caged dock in the blue uniform of convicts having already been sentenced to 20 years for inciting violence, raised his fists in defiance when the judge read out his verdict.
The judge issued the same sentence to more than 100 other defendants including Muslim Brotherhood leader Mohamed Badei, who has also been handed the death penalty in another trial, and his deputy Khairat al-Shater.
Morsi, who rose to the presidency in 2012 as the Brotherhood's compromise candidate after Shater was disqualified, won an election and ruled for only a year before mass protests prompted the military to overthrow him in July 2013.
He and dozens of other Islamist leaders were then detained amid a crackdown that left hundreds of his supporters dead.
Many of those sentenced on Saturday were tried in absentia, including prominent Islamic cleric Yusuf al-Qaradawi, who resides in Qatar.
Under Egyptian law, death sentences are passed on to the mufti, the government's interpreter of Islamic law, who plays an advisory role. The defendants can appeal even after the mufti's recommendation.
The court will pronounce its final decision on June 2.
"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.
Egyptian security forces stand guard outside the police academy during the trial of Egypt's deposed Islamist president Mohammed Morsi. (AFP Photo)
'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," Said Boumedouha of Amnesty said in a statement from the London-based rights watchdog.
In the Sinai on Saturday, gunmen shot dead three judges travelling from Ismailiya to El-Arish for a court hearing, in the first attack targeting the judiciary in the region.
Some of Morsi's fellow defendants included jihadists from Sinai, where militants have regularly carried out attacks against policemen and soldiers.
Morsi, 64, was spared the death sentence in the first of two trials that concluded on Saturday, in which the court advised death sentences for 16 defendants convicted of espionage.
They had been found guilty of colluding with foreign powers, the Palestinian Hamas and Iran to destabilise Egypt.
The court will pronounce the verdicts for Morsi and the remaining 18 defendants in that trial on June 2.
The court then delivered its verdict in the other case, in which Morsi and 128 defendants were accused of plotting jail breaks and attacks on police during the uprising that overthrew president Hosni Mubarak in 2011.
More than 100 of them were sentenced to death, along with Morsi.
Many of the defendants are Palestinians alleged to have worked with Hamas in neighbouring Gaza. They were tried in absentia along with 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.
With this verdict, Morsi and other former opposition members have been condemned for violence during the anti-Mubarak uprising, while Mubarak himself has been cleared of charges over the deaths of anti-government protesters during the 18-day revolt that toppled him.
Morsi was in prison when the anti-Mubarak uprising started on January 25, having been rounded up with other Brotherhood leaders a few days earlier.
On January 28, protesters fuelled by police abuses torched their stations across Egypt, prompting thousands of prisoners to escape when the police force all but collapsed.
Since Morsi's overthrow, the police force has largely been rehabilitated in public opinion, with government 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, is now president after having won elections last year.
He has pledged to eradicate the Brotherhood, once the largest political movement in the country.