The son of the former Egyptian President Mohamed Morsi has died from a heart attack, just three months after his father's sudden courtroom death.

Abdullah Morsi, who was in his 20s, fell ill while driving his car in Cairo and was rushed to a private hospital where doctors were unable to save him, the BBC reported.

The youngest son of Egypt's ousted leader had accused President Abdel Fattah al-Sisi's government of killing his father in June when he died dramatically at his trial.

Morsi, who became the country's first democratically elected president in 2012, was toppled by Sisi in a military coup the following year.

Abdullah Morsi, in his 20s, died on Wednesday night in Cairo after suffering a heart attack (pictured: during the trial over the breaking up the Rabaa el-Adaweya protests, at the police academy in Cairo in 2016)

Former Egyptian President Mohammed Morsi raises his hands inside a defendants cage in a makeshift courtroom at the national police academy in Cairo in 2015

The 67-year-old's courtroom death was compared to the killing of Jamal Khashoggi at the Saudi Embassy in Istanbul by Turkey's President Recep Tayyip Erdogan, who accused Egypt of murder.

Morsi went into cardiac arrest on June 17, shortly after speaking from his glass cage at his espionage trial to warn he had 'many secrets.'

'Morsi was struggling on the floor in the courtroom for 20 minutes. Authorities unfortunately did not intervene to save him,' Erdogan said in a televised speech in the days after his death. 'Morsi was killed. He did not die of natural causes.'

Erdogan led a service for the dead leader in Istanbul, as thousands of others offered prayers throughout the Middle East.

Abdullah Morsi had thanked Erdogan for his intervention, saying: 'No such event has ever been witnessed in history. Never have millions of people performed funeral prayers in absentia for anyone.'

Morsi hailed from Egypt's largest Islamist group, the now outlawed Muslim Brotherhood, and was elected president in 2012 in the country's first free elections following the ouster the year before of longtime autocrat Hosni Mubarak.

Turkish President Recep Tayyip Erdogan, who was a a close ally of Morsi, addressed mourners during a symbolic funeral ceremony at Faith Mosque in Istanbul the day after Morsi's death in Cairo

The military led by the army chief, now President Sisi, overthrew Morsi in 2013 after massive protests and crushed the Brotherhood in a major crackdown, arresting Morsi and many others of the group's leaders.

During his years in prison, Morsi, who was known to have diabetes, was often held in solitary confinement and was largely barred from receiving visitors. His family was only allowed to visit three times. While in detention, Morsi continued to appear in court on a range of charges.

In early court sessions he gave angry speeches until judges ordered him kept in a glass cage where they could turn off his audio.

Morsi's Brotherhood accused the government of 'assassinating' him through years of poor prison conditions.

A group of British parliamentarians had warned in March 2018 that Morsi's detention conditions, particularly inadequate treatment for his diabetes and liver disease, could trigger 'premature death'.