A top figure in the now-banned Islamist movement Muslim Brotherhood, Morsi had just addressed the court from a cage at a hearing on charges of espionage.
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" and called for crowds to gather at the funeral.