A top figure in the now-banned Islamist movement Muslim Brotherhood, Morsi had just spoken from a cage at a hearing on charges of espionage. State TV said the cause of death was a heart attack.
Morsi, who was 67, had been in custody since his removal after mass protests.
The Muslim Brotherhood said the death was a "full-fledged murder".
Activists and his family had long said Morsi was not receiving treatment for serious health problems such as high blood pressure and diabetes, and was constantly being held in solitary confinement.