CAIRO — One of Egypt’s highest courts overturned a death sentence imposed on Mohamed Morsi, who was the country’s first democratically elected president and was ousted in 2013 by the military.

Mr. Morsi, who is serving a life sentence in prison for offenses related to espionage and inciting violence, is likely to remain in prison indefinitely.

The annulment of his death sentence — as well as the sentences against five other leaders of Mr. Morsi’s Muslim Brotherhood movement — suggests the government’s reluctance to execute leaders of the Brotherhood, which still maintains some public support after its role in the ouster of President Hosni Mubarak in 2011.

The Brotherhood, which held power for just over a year, has been classified as a terrorist group by the government of Abdel Fattah el-Sisi, the president and a former military leader, and thousands of the group’s leaders and members have been jailed or killed or have gone into exile. Even so, observers widely believe that executing top leaders like Mr. Morsi could lead to a new surge of violence.