Cairo(CNN) Mohamed Morsy went from prison to the presidency. And now he's going back to prison.
The ousted President was convicted on charges of violence and inciting violence and sentenced to 20 years in prison for the torture of protesters outside the presidential palace in December 2012. But he was acquitted of murder in the deaths of protesters.
He stood trial with 14 co-defendants, including some of his presidential staff. All 14 co-defendants were also convicted of violence and inciting violence, and all were also acquitted of murder.
Morsy, who became Egypt's first democratically elected President in June 2012, was deposed by a popularly backed military coup in July 2013.
After the sentencing, his Freedom and Justice Party called the trial a "travesty of justice."
"This is a sad and terrible day in Egyptian history," the party said in a statement Tuesday. "Coup leaders have sentenced Mohamed Morsi to decades in prison for nothing more than championing the democratic will of the people."
But Ramy Ghanem, a civil plaintiff lawyer representing one of the torture victims, said the conviction was fair.
"This is a very appropriate and clear verdict on people that committed the crime," he said. "This, in fact, was the maximum sentence for the charges. The surprise was the acquittal."
Hoda Nasrallah, a lawyer representing two torture victims, called the outcome of the case typical for Egypt.
"All the cases involving big gatherings and demonstrations in which protesters were killed usually see the culprits walk free. This case is a manifestation of this," she said.
"The public will always see the verdicts as politicized because there is no regime put on trial before falling, so everyone sees it as settling scores. It's not about Morsy only, but it also applies to (former Egyptian President Hosni) Mubarak and others. This is the status quo in Egypt. We wish we could see the trial of a regime when it is in power, not after that."
Nasrallah called for a "fair trial," criticizing the fact that seven men killed during the December 2012 clashes were not included in this case, because they were affiliated with the Muslim Brotherhood, and that the involvement of other sides, including police, wasn't investigated.
Morsy can appeal his conviction.
But Muslim Brotherhood spokesman Mohamed Montasser has already issued an ominous warning on Twitter:
"Sentencing the president won't pass," he said. "The revolution will be ignited, popular anger will increase and we promise you unexpected revolutionary surprises."
At various points in the trial, Morsy said that he was still the President of Egypt and refused to recognize the court as legal.
Attorney Mohamed Selim El-Awa cited constitutional articles to the court that stipulated the steps for removing a president and putting him on trial -- something that required the approval of two-thirds of the parliament and a special court made of the country's top judges.
A judge on Tuesday rejected the argument presented by El-Awa and court-appointed lawyer El-Sayed Hamed that the court had no jurisdiction.
Hamed was appointed by the court after Morsy's defense team withdrew. He told CNN he met with Morsy about three times over the past 16 months. He praised the "neutrality of the court," rebuffing accusations of politicization.
"Before the case reached the court, it was dominated by politics more than the law, and I said this in my argument at the court. But by reaching the court, the court examined the documents from the legal aspect and saw that they were innocent of accusations of murder and guilty of other charges. Consequently, we will appeal this sentence," he told CNN.
Early in the trial, Morsy and his co-defendants were held in a metal cage in court. Later, that cage was enclosed in soundproof glass.
This is the first trial Morsy was referred to after his removal from power. He is also standing trial in three other cases, including two on charges of espionage.
The third trial involves a 2011 jailbreak. Morsy and 18 other members of the banned Muslim Brotherhood allegedly broke out of the Wadi-Natroun prison, Egyptian state-run media reported.
In that trial, Morsy and his 130 co-defendants, who include 71 Palestinians tried in absentia, are accused of collaborating with the Palestinian Islamist group Hamas and the Lebanese Shia group Hezbollah to break into several prisons across Egypt in January 2011 and facilitating the escape of Morsy and 20,000 others.
In May, Morsy is scheduled to start a fifth trial -- this one on charges of insulting the judiciary.