Egypt's deposed Islamist president Mohammed Morsi was on Saturday sentenced to 40 years in prison on charges of leaking secret state documents to Qatar when he was in office.
The decision was made by the Cairo Criminal Court, which announced two separate jail terms of 25 years and 15 years against Morsi on different counts.
Two former aides to Morsi were sentenced to life terms, which under Egyptian law is 25 years.
The court also confirmed preliminary death sentences given last month to six defendants in the same case.
The six, convicted of espionage, included three journalists, who were tried in absentia. Two of the three are employees of the Qatari television network Al Jazeera.
Confirmation of the death verdicts came after the country's chief Islamic legal authority, the grand mufti, approved them, as required by Egyptian law in cases involving death sentences.
The rulings against Morsi and all other defendants can be appealed.
Qatar was a key ally of Morsi's now-banned Muslim Brotherhood.
Human Rights group Amnesty International condemned Saturday's death sentences.
"While this outcome is appalling, it is sadly not surprising," Magdalena Mughrabi-Talhami, the watchdog’s deputy director of the Middle East and North Africa Programme, said.
"Egypt's broken and utterly corrupted justice system is now little more than a handy tool for the authorities' repression of any vestiges of opposition or criticism," she added in a statement.
The Egyptian government has repeatedly rejected criticism of heavy-handed sentences against Islamists, saying that the country's courts operate independently.
Morsi, Egypt's first democratically elected president, was toppled by the military in 2013 following mass protests against his rule.
In June 2015, another court sentenced him to death after convicting him of involvement in a mass prison escape during Egypt's 2011 uprising. This sentence is subject to appeal.
The court also handed him a life term on charges of conspiring with foreign organizations in conducting the jailbreak.
He is being tried in a separate case on charges of insulting the judiciary.
Several senior leaders in the Muslim Brotherhood and their followers have been sentenced to death in different cases since Morsi's toppling.
The Islamist group has dismissed the sentences and other harsh verdicts as politically motivated.