An Egyptian court sentenced hundreds to jail for murder and illegally protesting on Monday after a mass trial criticized by rights groups.
But it acquitted an Irish student, a high-profile detainee who says he was tortured in custody.
Ibrahim Halawa was on trial with three of his sisters and nearly 500 others, all charged with, among other crimes, breaking into a mosque, killing 44 people, and illegal possession of firearms.
The incidents followed the military's ouster of former Islamist president Mohamed Mursi in 2013.
The defendants were all facing the death penalty but none received it. Instead the judge sentenced hundreds to jail terms including 43 people to life in prison, which in Egypt is 25 years, and five years of parole.
Another 17 people were sentenced to 15 years in prison, 67 to 10 years, and 216 to five years. Two minors were sentenced to 10 years in absentia and six to five years.
A dual Egyptian-U.S. citizen involved in the trial was also acquitted.
Egyptian rights activists say they have faced the worst crackdown in their history under President Abdel Fattah al-Sisi, who was elected president in 2014 a year after as armed forces commander he led the military's toppling of Mursi.
Halawa was 17 when he was arrested with hundreds of others in 2013, as part of a crackdown on protests in Egypt. He has been held in pre-trial detention since then, and has said he has been regularly tortured.
"Today's verdict is long overdue. Ibrahim was arrested as a child for the 'crime' of attending a protest, tortured, and tried facing the death penalty alongside adults in an unfair mass trial," said Maya Foa, director of human rights group Reprieve, which is assisting Halawa.
"For years, these court proceedings – which were designed to punish political dissent – made a mockery of justice. The wider international community – including the EU, which helps to fund Egypt's courts – must also call urgently on Egypt to end its use of patently illegal mass trials."
Irish Prime Minister Leo Varadkar welcomed Halawa's acquittal and said the case had been an "extraordinarily protracted" one.
"Now that Ibrahim has been cleared of all charges, I expect he will be released as soon as possible and can return home to his family. The Government will facilitate his return home at the earliest opportunity," he said in a statement.