Supporters turned out in their masses last night to mourn the death of Egypt's ousted president Mohamed Morsi.

The Muslim Brotherhood leader had risen to office in the country's first elections in 2012 and was ousted a year later by the military.

He collapsed in court and died, just after telling an espionage trial that he could reveal 'many secrets' , but that they would breach the country's national security.

State TV said Mr Morsi died before he could be taken to hospital.

Last night mourners from Istanbul to Jerusalem performed prayers in absentia for the former president, while the streets of Cairo seemed to remain calm, with guards continuing to guard Cairo's Tora prison, where Morsi was being tried.

Former Egyptian president Mohamed Morsi has died in court, state television reported on Monday. Pictured: Morsi on trial for espionage charges in 2016

Muslim Brotherhood and ousted president Mohammed Morsi supporters clash with Egyptian riot police during a demonstration in the streets of Cairo in 2013

Mourners were pictured praying at the Al-Aqsa Mosque in Jerusalem following the announcement of his death

In front of the Consulate General of Egypt in Istanbul people performed a funeral prayer

Morsi's son Ahmed posted on Facebook after his death saying he would 'meet his father in heaven'

While many mourned, protests were also said to have been happening late into the night outside the Egyptian embassy in Nouakchott, the capital of Mauritania, in protest of his treatment and condemning the circumstances of his death.

Mr Morsi has been in prison undergoing multiple trials ever since the military ousted him in July 2013 and launched a massive crackdown on his Muslim Brotherhood and other Islamists.

Monday's session was part of a retrial, being held inside Cairo's Tura Prison, on charges of espionage with the Palestinian Hamas militant group.

Mr Morsi's son Ahmed confirmed the death of his father in a Facebook post.

Mohammed Sudan, a leading member of the Muslim Brotherhood in London, described Mr Morsi's death as 'premeditated murder', saying that the former president was banned from receiving medicine or visits and there was little information about his health condition.

Last night mourners gathered in Istanbul to express their sadness of Morsi's death

This is while officers continued to guard Cairo's Tora prison (above) where Morsi was being tried

'He has been placed behind a glass cage (during trials). No-one can hear him or know what is happening to him. He hasn't received any visits for a months or nearly a year. He complained before that he doesn't get his medicine. This is premeditated murder. This is slow death.'

The judicial official said Mr Morsi had asked to speak to the court during the session.

The judge permitted it, and Mr Morsi gave a speech saying he had 'many secrets' that, if he told them, he would be released, but he added that he was not telling them because it would harm Egypt's national security.

Mr Morsi was a longtime senior figure in Egypt's most powerful Islamist group, the Muslim Brotherhood.

Morsi during his trial on charges of espionage in 2015

He was elected in 2012 in the country's first free presidential election, held a year after an Arab Spring uprising ousted Egypt's longtime authoritarian leader Hosni Mubarak.

His Muslim Brotherhood also held a majority in parliament.

The military, led by then-defence minister Abdel-Fattah el-Sissi, ousted Mr Morsi after massive protests against the Brotherhood's domination of power.

Mr El-Sissi was subsequently elected president and has waged a massive crackdown on Islamists and other opponents since.

Since Mr Morsi's ousting, Egypt's government has declared the Brotherhood a terrorist organisation and largely crushed it with a heavy crackdown.

State TV in Egypt announcing the death of Morsi during his trial earlier on Monday afternoon

Former Egyptian president Mohamed Morsi has died in court, state television reported on Monday. Pictured: Morsi on trial for espionage charges in 2016

Tens of thousands of Egyptians have been arrested since 2013, mainly Islamists but also secular activists who were behind the 2011 uprising.

He has been sentenced to 20 years after being convicted of ordering Brotherhood members to break up a protest against him, resulting in deaths.

An earlier death sentence was overturned.

Multiple cases are still pending.

Mr Morsi was held in a special wing in the sprawling Tora detention complex nicknamed Scorpion Prison.

People perform funeral prayer in absentia over the demise of Egypt's first democratically elected President Mohamed Morsi in Jerusalem on Monday

Tahrir Square in central Cairo pictured this evening after the news of Morsi's death was reported by state media

Rights groups say its poor conditions fall far below Egyptian and international standards.

Mr Morsi's son Ahmed confirmed the death of his father in a Facebook post.

Turkish President Recep Tayyip Erdogan paid tribute to Morsi after news of his death broke - calling him a 'martyr.'

'May Allah rest our Morsi brother, our martyr's soul in peace,' said Erdogan, who had forged close ties with Morsi.

Relations between Turkey and Egypt have been virtually non-existent since the Egyptian military, then led by Abdel Fattah al-Sisi, in 2013 ousted Islamist president Morsi. Sisi has since become president.

German Chancellor Angela Merkel and Morsi shake hands at a joint press conference in Berlin in 2013

Erdogan has strongly denounced Morsi's ouster and called for the release of Muslim Brotherhood prisoners in Egypt.

Speaking in Istanbul, Erdogan again took aim at Sisi, calling him a 'tyrant' who took power in a 'coup' and who has trampled on democracy.

'The West has remained silent,' Erdogan said.

Foreign Minister Mevlut Cavusoglu said: 'The coup moved him (Morsi) away from the power but his memory will not be erased.'

President of Turkey Recep Tayyip Erdogan paid Tribute to Morsi after his death was announced on Monday

Erdogan, right, and former Egyptian President Morsi together at a press conference in 2012