Former Egyptian President Mohamed Morsi, the country's first democratically elected head of state who was later ousted from power, was buried Tuesday after his dramatic collapse and death inside a Cairo courthouse Monday.

A member of Morsi's defense team said family members attended funeral prayers in the mosque of Cairo's Tora prison, which was followed by the burial at a cemetery in the Egyptian capital's eastern district of Nasr City.

Morsi's son Ahmed said security agencies refused to allow Morsi to be buried at the family's cemetery in his hometown in Sharqia province, and instead had him interred at a Cairo cemetery for prominent Islamists.

Archive Egypt-Mohamed Morsi VOA’s senior analyst Mohamed Elshinnawi asked Michele Dunne, Director of Middle East Program at the Carnegie Endowment for International Peace, about the impact of Morsi's death on Egyptian politics

Officials said the 67-year-old had just addressed the court in Cairo during his trial on espionage charges when he collapsed Monday. They said Morsi spoke for five-minutes from the glass cage he is kept in during the trial and a few minutes later fell to the ground.

State television said Morsi was taken to the hospital, but was dead on arrival from an apparent heart attack

He was buried Tuesday.

Morsi, long a top figure in the Islamic group, the Muslim Brotherhood, was overthrown as president in 2013 by Egypt's military after mass protests against his rule.

FILE - Members of the Muslim Brotherhood and supporters of Egypt's President Mohamed Mursi hold pictures of him as they react after the Egyptian army's statement was read out on state TV, at the Raba El-Adwyia mosque square in Cairo, July 3, 2013.

The Muslim Brotherhood's Freedom and Justice political party said in a statement published on its website Monday that Egyptian authorities are responsible for Morsi's "deliberate slow death" because they "withheld medication and gave him disgusting food. They did not give him the most basic human rights." The group called for masses to gather at his funeral in Egypt as well as at Egyptian embassies around the world.

The leading member of the Muslim Brotherhood in London, Mohammed Sudan, said "This is premeditated murder. This is slow death."

After Morsi's ouster, Egypt's military put the former president in prison, where he has been since 2013, and cracked down on the Muslim Brotherhood.

Morsi has faced multiple trials on charges that included spying for Iran and Qatar and for the killing of Egyptian protesters during demonstrations in 2012. He was on trial Monday facing charges of espionage related to suspected contacts with the Palestinian group Hamas, which has close ties to the Muslim Brotherhood.

Human Rights Watch has described the charges against Morsi as political. The group's Middle East director, Sarah Leah Whitson, said on Twitter Monday that Morsi's imprisonment was "cruel and inhumane" and said he was "deprived of family visits and medical care."

Amnesty International called for Egyptian authorities to conduct an impartial investigation into the circumstances of Morsi's death, including the medical care he was receiving.

Egypt's chief prosecutor said a team of forensic experts will examine Morsi's body to determine the cause of death.

Officials say security forces have been put on high alert following Morsi's death.

Global reaction

Turkey's President Recep Tayyip Erdogan, who was a strong ally of Morsi when he was in power, paid tribute to the former president on Monday calling him a "martyr," while calling current Egyptian President Abdel-Fattah el-Sissi "cruel."

Qatar's ruler Sheikh Tamin bin Hamad al-Thani, another backer of Morsi, tweeted his condolences, saying he received the news of Morsi's death with "deep sorrow."

Morsi's rise, fall

Morsi was elected president in 2012 in Egypt's first free elections following the ouster the previous year of longtime leader Hosni Mubarak.

Morsi promised a moderate Islamist agenda and a new democratic era, but his time in power proved difficult, with critics accusing him of trying to amass power and impose the Muslim Brotherhood's conservative brand of politics on the country.

After his arrest, Morsi gave angry speeches in court and continuously insisted he remained Egypt's legitimate president. His speeches led judges to order him kept in a glass cage during court sessions where they could turn off his audio.