Egypt's former President Mohammed Morsi, ousted by the military in 2013 after one year in office, has collapsed in a courtroom and died, officials say.
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.
What happened in court?
Morsi collapsed moments after addressing the court in Cairo over charges of espionage related to suspected contacts with the Palestinian Islamist group Hamas, which had close ties to the Muslim Brotherhood.
He spoke for some five minutes from a soundproof glass cage which officials said was designed to prevent him from disrupting proceedings. Morsi was pronounced dead in hospital at 16:50 local time (14:50 GMT) and an initial report showed no signs of recent injuries on the body, Egypt's public prosecutor said.
Last month, his family said authorities had repeatedly denied access to him and that they knew little about the state of his health. During his time in prison, Morsi was allowed only three visits from relatives and was denied access to his lawyers or a doctor, according to human rights group Amnesty International.
His son Abdullah told the Reuters news agency he did not know the location of the body and that authorities were refusing to allow Morsi to be buried in his native Nile Delta province of Sharqiya.
Morsi, who became Egypt's first democratically elected leader in 2012, had already been sentenced to more than 45 years in prison in three separate trials, including for leading an outlawed group, detention and torture of anti-government protesters and leaking state secrets.
He had always rejected the authority of the courts, and his supporters denounced the trials as politically motivated and attempts to give legal cover to a coup based on unreliable witnesses and scant evidence.
A death certain to inflame passions
The death of a leader, remembered by many as Egypt's first democratically elected president, is certain to inflame passions among his supporters and allies in Egypt and beyond. Turkey's President Recep Tayyip Erdogan has been quick to describe him as a martyr. Others are certain to do the same.
There has long been concern about the politicised trials which have kept him in prison, as well as his conditions of confinement. Morsi had a history of ill-health.
But last year, a British parliamentary panel reported he was being kept in solitary confinement for 23 hours a day, which they concluded could be classified as torture. They warned this could lead to premature death.
His sudden collapse comes at a time when the United States, reportedly at the request of Egyptian President Abdul Fattah al-Sisi, is working to designate the Muslim Brotherhood as a foreign terrorist organisation. The death of one its most senior figures will deepen the anger and anxiety in this global Islamist movement.
What has the reaction been?
The Muslim Brotherhood's political arm, the Freedom and Justice party, said Morsi's death amounted to an "assassination", and urged supporters to gather at the funeral and demonstrate outside Egyptian embassies around the world.
"They placed him in [solitary] confinement throughout his detention which exceeded five years, prevented medicine and provided poor food... They prevented doctors and lawyers and even communicating with his family. They deprived him from the simplest human rights."
Turkey's President Recep Tayyip Erdogan, who was a close ally, blamed Egypt's "tyrants" for the death while the Emir of Qatar, Sheikh Tamim bin Hamad Al Thani, another ally, expressed his "deep sorrow".
Crispin Blunt MP, who led a panel of British MPs who had warned about Morsi's health, called for a "reputable independent international investigation", and said Egypt's government had a "duty to explain his unfortunate death".
Amnesty's deputy director for the Middle East and North Africa Magdalena Mughrabi said: "[Morsi] was held in solitary confinement for almost six years, placing a considerable strain on his mental and physical wellbeing... [H]e was effectively cut off from the outside world."
Human Rights Watch Middle East director Sarah Leah Whitson said Morsi's death was "terrible but entirely predictable".
Who was Morsi?
Born in the village of El-Adwah in 1951, Morsi studied Engineering at Cairo University in the 1970s before moving to the US to complete a PhD.
He was chosen as the Muslim Brotherhood's presidential candidate for the 2012 election after the movement's preferred choice was forced to pull out. During his turbulent year in office, Morsi was accused of mounting an Islamist coup and mishandling the economy.
Public opposition to his government grew and millions of anti-government protesters took to the streets across Egypt to mark the first anniversary of the day he took office, on 30 June 2013.
Three days later, the army suspended the constitution, announced an interim government ahead of new elections and detained Morsi, who denounced the move as a coup. Abdul Fattah al-Sisi, then army chief, was elected president in 2014 and re-elected last year in polls rights groups called "farcical".
After Morsi's removal, authorities launched a crackdown on his supporters and other dissent, and hundreds of people have been killed and tens of thousands others detained in conditions often described as being in violation of their human rights.