An Egyptian court has upheld a life sentence for ousted Islamist President Mohammed Morsi and confirmed death sentences against 16 others over charges of conspiring with foreign groups, including the Palestinian militant group Hamas.

Judge Shaaban al-Shami issued the ruling, which can be appealed, on Tuesday. He is expected to rule later Tuesday on an earlier death sentence handed to Morsi over a mass prison break during the 2011 uprising.

The 16 defendants whose death sentences were upheld include three senior members of Morsi's Muslim Brotherhood group. The other 13 were tried in absentia. Morsi was among 17 defendants sentenced to life in prison.

The military overthrew and detained Morsi, Egypt's first freely elected president, in July 2013 amid massive protests demanding his resignation.