CAIRO: Egypt's first democratically elected president Mohammed Morsi took his last breath on Monday in a courtroom during a trial session. He was buried in Medinat Nasr, in eastern Cairo, with his family present. The funeral prayer was said in Tora prison hospital where he was declared dead on Monday, his lawyer Abdel Moneim Abdel Maksoud said.

"He was speaking before the judge for 20 minutes then became very animated and fainted. He was quickly rushed to the hospital where he later died," a judicial source was quoted as saying. The 67-year-old was at the session over accusations of espionage, according to BBC

Morsi became Egypt's first democratically elected president in 2012 after the 2011 Arab Spring saw the end of former president Hosni Mubarak's 30-year rule. He was then deposed following mass protests and a military coup in July 2013.

The ousted leader had remained in custody since then, while the movement to which he belonged, the Muslim Brotherhood, has since been outlawed, Al Jazeera reported.

The Cairo Criminal Court had adjourned the trial of Morsi and 23 others in the case of "collaborating with Hamas" for tomorrow.

In November 2016, the Court of Cassation scrapped the life imprisonment the sentence for Morsi and 21 other defendants, including some who had received the death penalty, in the same case, and ordered a retrial.

Morsi, a member of the Muslim Brotherhood, was toppled in the military overthrow in 2013 and had been in detention ever since.

WATCH: India needs to learn from Hong Kong; Watch how protesters made way for ambulance