Egypt's former President Mohamed Morsi has passed away during a trial court session in the capital Cairo, state television says.
It said 67-year-old Morsi fainted during a court session on Monday and died afterwards.
"He was speaking before the judge for 20 minutes then became very animated and fainted. He was quickly rushed to the hospital where he later died," a judicial source said.
Morsi, a senior figure in the Muslim Brotherhood organization, was Egypt’s first democratically-elected president after the 2011 revolution, but he was deposed following a military coup led by Abdel Fattah el-Sisi in July 2013.
He had been serving a 20-year prison term on charges of ordering the arrest and torture of protesters, a 25-year jail term on charges of passing intelligence to Qatar and a three-year term for insulting the judiciary.
In November 2016, the Court of Cassation scrapped the life imprisonment sentence for Morsi and 21 other defendants, including some who had received the death penalty, in the same case and ordered a retrial.
Turkish President Recep Tayyip Erdogan became the first world leader to pay tribute to Morsi, calling him a martyr.
"May Allah rest our brother Morsi, our martyr's soul in peace," said Erdogan, who had forged close ties with the late former president.
The Muslim Brotherhood has labeled the death as a full-fledged murder. In a strongly worded statement, the organization has called on Egyptians to gather for a mass funeral. It said Egyptian authorities were responsible for Morsi's deliberate slow death.
In addition, Human Rights Watch described the news of his death as "terrible" but "entirely predictable", citing the Egyptian government's "failure to allow him adequate medical care.”
Egypt's public prosecutor said the former president was pronounced dead at 4:50 p.m. local time (02:50 GMT) at the hospital, and that a medical report showed no apparent recent injuries on his body.
Morsi suffered from medical neglect during his imprisonment as well as poor conditions in jail.
Last year, a report by a panel of UK legislators and attorneys warned that the lack of medical treatment could result in Morsi's "premature death.”
"Our conclusions are stark," Crispin Blunt, the Detention Review Panel's chairman, said at the time. "The denial of basic medical treatment to which he is entitled could lead to his premature death."
They panel said that Morsi was being kept in solitary confinement for 23 hours a day, which under the UN guidelines, would classify as torture.
The Egyptian Interior Ministry declared a state of alert on Monday, notably in Mursi's home province of Sharqiya in the Nile
Amnesty international has also called for fair, transparent, and comprehensive investigation into Morsi's death.
“Egyptian authorities had the responsibility to ensure that, as a detainee, he had access to proper medical care," Amnesty said.
It added, “Mohamed Morsi was subjected to enforced disappearance for months after his detention, before first appearing in front of a judge on November 4, 2013. He was held in solitary confinement for almost six years, placing a considerable strain on his mental and physical well-being and violating the absolute prohibition against torture and other ill-treatment under international law. During this six-year period, he was effectively cut off from the outside world – he was allowed only three family visits and was prevented from access to his lawyers or a doctor."