Morsy, 67, was in court because of a spy case when he suffered a heart attack, Egyptian head of state Al Ahram reported online.
He had received a request to make a statement before fainting and dying. The former president was taken to a nameless hospital.
Morsy, a rigorous Islamist trained in Southern California, was brought to power in June 2012 following the Arab Spring uprising the year before; Hosni Mubarak's long-standing death brought rule.
Morsy was a former member of the Muslim Brotherhood and was committed to reaching out to the widest possible audience.
However, during his year in power, critics claimed he had become an authoritarian leader who had pushed through a conservative agenda.
3, Morsy and the political wing of the Muslim Brotherhood movement were toppled by a coup, with the Muslim Brotherhood banned by the government after the military took power and declared it a terrorist organization.
About 1,000 Egyptians – many of them Morsy followers – were killed in protests against the military government.
Following his fall, Morsy was mass-marketed, together with Mohamed Badie, the spiritual leader of the Muslim Brotherhood, and more than 100 suspected members of the banned group According to the state media.
In 2015, he was sentenced to death for conspiracy with the Palestinian group Hamas, the Iranian Revolutionary Guard, and other foreign organizations for a jailbreak during the 2011 uprising.  These two judgments were widely criticized as politically outstanding.
Morsy was also sentenced to 25 years imprisonment for sharing state secrets with Qatar, and received an additional 15-year sentence for other minor charges.
In 2016, Morsy's death sentence and life imprisonment were lifted.
A report by a panel commissioned by Morsy's family, composed of British parliamentarians, said last year that detention conditions are "cruel, inhuman and degrading treatment" and "the threshold for torture in Conformity with the law could achieve (with) Egyptian and international law. "The panel wrote that Morsy receives inadequate medical care," which is likely to lead to premature death. "
Vasco Cotovio of CNN contributed to this report.