Egypt’s first democratically elected president Mohammed Morsi and 19 co-defendants have been sentenced to three years in prison on charges of insulting the judiciary, state television reported on its website.

The Cairo Criminal Court, which has issued the sentence, convicted Morsi of defaming the judiciary in a public speech he made more than four years ago “with the aim of spreading hate,” the report said.

The case involves 25 defendants, five of whom including prominent rights activist Alaa Abdel-Fattah and political analyst Amr Hamzawy were fined 30,000 Egyptian pounds each ($1,688). Abdel-Fattah is serving a five-year sentence for taking part in an illegal protest in 2013. Hamzawy lives in exile.

All the defendants are accused of insulting the judiciary by making statements that were made public either on TV, radio, social media or in publications that the court found to be inciting and expressing hatred toward the court and the judiciary.

The court ordered Morsi to pay 1 million Egyptian pounds ($56,270) as compensation to one of the judges. It also ordered 23 of the defendants, including Morsi, to pay 1 million Egyptian pounds each to a powerful union of judges known as the “Judges Club,” state-run Al-Ahram newspaper reported.

The ruling can be appealed.

Abdel-Fattah is an outspoken blogger and an icon of the 2011 uprising that toppled longtime autocrat Hosni Mubarak. He has been in and out of prison in the years since Mubarak’s ouster. A software engineer by profession, he also campaigned against the policies of the military council that ruled Egypt for nearly 17 months following Mubarak’s ouster.

In 2013, Morsi, when he was in office, accused in a televised speech a judge of overseeing fraud in previous elections.

Morsi was removed from power by a military coup in mid-2013 led by current president Abdel-Fattah el-Sissi.

He has been tried in several different cases since his ouster.