You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
Mursi, a top figure in the now-banned Muslim Brotherhood, had been in jail since being toppled by the military in 2013 after barely a year in power, following mass protests against his rule.
His death is likely to pile up international pressure on the Egyptian government over its human rights record, especially conditions in prisons where thousands of Islamists and secular activists are held.
The public prosecutor said he had collapsed in a defendants' cage in the courtroom shortly after addressing the court, and had been pronounced dead in hospital at 4:50pm (local time). It said initial checks had shown no signs of recent injury on his body.
The Muslim Brotherhood described Mursi's death as a "full-fledged murder" and called for masses to gather at his funeral in Egypt and outside Egyptian embassies around the world.
Mursi's family previously said his health had deteriorated in prison and that they were rarely allowed to visit.
His son said authorities were refusing to allow the family to lay him to rest in the family burial grounds in his native Nile Delta province of Sharqiya.
Abdullah Mohamed Mursi also told Reuters that authorities were only communicating with the family through their lawyers.
"We know nothing about him and no one is in touch with us, and we don't know if we are going to wash him or say a prayer to him or not," Abdullah said.
Amnesty International called for an "impartial, thorough and transparent" investigation into Mursi's death.
"The news of Mohamed Mursi's death in court today is deeply shocking and raises serious questions about his treatment in custody," the group said in a statement. "Egyptian authorities had the responsibility to ensure that, as a detainee, he had access to proper medical care."
British MP Crispin Blunt, who had led a delegation of UK lawmakers and lawyers last year in putting out a report on Mursi's detention, slammed the conditions of Mursi's incarceration.
"We want to understand whether there was any change in his conditions since we reported in March 2018, and if he continued to be held in the conditions we found, then I'm afraid the Egyptian government are likely to be responsible for his premature death," he said in remarks to the BBC.
Decades of repression
After decades of repression under Egyptian autocrats, the Brotherhood won a parliamentary election after a popular uprising toppled Hosni Mubarak and his military-backed establishment in 2011.
Mursi was elected to power in 2012 in Egypt's first free presidential election, having been thrown into the race at the last moment by the disqualification on a technicality of millionaire businessman Khairat al-Shater, by far the Brotherhood's preferred choice.
His victory marked a radical break with the military men who had provided every Egyptian leader since the overthrow of the monarchy in 1952.
Mursi promised a moderate Islamist agenda to steer Egypt into a new democratic era in which autocracy would be replaced by transparent government that respected human rights and revived the fortunes of a powerful Arab state long in decline.
But the euphoria that greeted the end of an era of presidents who ruled like pharaohs did not last long.
The stocky, bespectacled engineer, born in 1951 in the dying days of the monarchy, told Egyptians he would deliver an "Egyptian renaissance with an Islamic foundation."
Instead, he alienated millions who accused him of usurping unlimited powers, imposing the Brotherhood's conservative brand of Islam and mismanaging the economy, all of which he denied.
State of alert
Security sources said the Interior Ministry had declared a state of alert on Monday, notably in Sharqiya.
Mursi had been in court for a hearing on charges of espionage emanating from suspected contacts with the Palestinian Islamist group Hamas, which had close ties to the Brotherhood.
His body was taken to the Tora prison hospital, state television reported. A heavy security presence was outside the prison on Monday night.
Mursi's lawyer said his health had been poor in jail. "We had put in several requests for treatment, some were accepted and others were not," the lawyer, Abdel-Menem Abdel-Maqsood, told Reuters.
Mursi was serving a 20-year prison sentence for a conviction arising from the killing of protesters during demonstrations in 2012, and a life sentence for espionage in a case related to the Gulf state of Qatar. He had denied the charges.
Turkish President Tayyip Erdogan mourned his fellow Islamist as a martyr.
"Putting doubts aside, he has become a martyr today with the fulfilment of God's order. ... Our prayers are with him," Erdogan said.
"Condolences to all my brothers who walked the same path as he did. Condolences to the people of Egypt. Condolences to his family and those close to him."
The Palestinian Islamist group Hamas said Mursi had "served Egypt and the (Muslim) nation and the Palestinian cause."
Qatar's emir, Sheikh Tamim bin Hamad Al Thani, a backer of Mursi and his Brotherhood, tweeted his condolences to Mursi's family "and to the brotherly Egyptian people."