Updated

An investigating judge has ordered the detention of Egypt's ousted president over alleged contacts with Hamas to help in his escape from prison in 2011, the official state news agency reported Friday in the first official word on Mohammed Morsi's status since he was overthrown by the military on July 3.

The announcement came hours before mass protests were set to take place across the nation in response to a call by military chief Gen. Abdel-Fatah el-Sissi for a show of popular support for his anticipated crackdown on Morsi's supporters and radical Islamists loyal to the ousted leader who have been attacking security forces in the strategic Sinai Peninsula.

The Muslim Brotherhood, the Islamist group from which Morsi hails, also called for mass protests on Friday.

The rival rallies and the announcement that Morsi faces accusations that could carry the death penalty on conviction further raised the specter of violence between the two camps.

Starting legal proceedings against Morsi, however, could also halt repeated calls by Western governments to free Morsi or file charges against him.

The military and the police have pledged to protect Friday's protesters, and the army deployed tens of thousands of troops across the country, supported by armor and helicopters.

The MENA news agency said Morsi has been detained for 15 days pending the completion of the investigation into the accusations. His detention can be extended as the inquiry continues. The news agency indicated that Morsi has already been interrogated.

Senior Brotherhood official Essam el-Erian rejected the detention order, saying Morsi continues to enjoy immunity as the nation's "legitimate" president, and he can stand trial only as part of a constitutional process that allows that.

The detention order, he wrote on his official Facebook page, "lays bare the fascist nature of military rule ... our response will be with millions in peaceful rallies in the squares."

The case against Morsi is rooted in the mass jailbreak of more than 30 Muslim Brotherhood leaders from a prison northwest of Cairo during the 2011 popular uprising that toppled Morsi's predecessor, autocrat Hosni Mubarak. There have been many reports in the Egyptian media that the Brotherhood collaborated with Hamas, its Palestinian wing, and Hezbollah militants in Lebanon to arrange the breakout.

Muslim Brotherhood officials have said they were aided by local residents in breaking out of prison, not foreigners. However, a court in the Suez Canal city of Ismailia has heard testimonies from prison officials and intelligence officers strongly indicating that Morsi and his Brotherhood colleagues were freed when gunmen led by Hamas operatives stormed the Wadi el-Natroun prison.

Hamas has consistently denied any involvement. On Friday a spokesman for the militant group, Sami Abu Zuhri, condemned Morsi's detention order. "The Egyptian decision is an attempt to drag Hamas into the Egyptian conflict," he said. "We call on the Arab League to bear its responsibility in facing the incitement against Hamas."

Morsi's only account of his jailbreak came in a frantic phone call he made to Al-Jazeera Mubasher TV moments after being freed. "From the noises we heard ... It seemed to us there were (prisoners) attempting to get out of their cells and break out into the prison yard, and the prison authorities were trying to regain control and fired tear gas," Morsi said in the call.

By the time they got out, the prison was empty, and there was no sign of a major battle, he said.

Other Brotherhood leaders gave similar accounts of the jailbreak, in which at least 14 members of the security forces were killed and the jail's documents and archives destroyed.

The Brotherhood has been demanding that Morsi, Egypt's first freely elected president, be reinstated. His ouster in a military coup followed days of nationwide demonstrations, when millions turned out to demand his resignation after just one year in office.

Egypt's military, which views Hamas as a threat to Egypt's national security, has been holding Morsi in an undisclosed location since deposing him.

The MENA report said Morsi was being investigated over allegations of collaborating with Hamas "to carry out anti-state acts, attacking police stations, army officers and storming prisons, setting fire to one prison and enabling inmates to flee, including himself, as well as premeditated killing of officers, soldiers and prisoners."

Friday's surprise announcement about Morsi comes as Egypt's divisions appear to grow deeper, with Islamists stepping up their campaign against el-Sissi and state media whipping up sentiments against the Islamists.

On Thursday, the spiritual leader of the Brotherhood, Mohammed Badie, said ousting Morsi was a worse crime than if el-Sissi had destroyed the Kaaba, Islam's holiest site -- an attempt to fire up the religious fervor in the pro-Morsi camp ahead of Friday's rallies.

It was not clear what el-Sissi meant by seeking a mandate against violence -- and how far the military would go. The most explosive move would be if troops were to eventually try to clear the two major sit-ins by Morsi's supporters. The largest has been outside Cairo's Rabaa al-Adawiya mosque, where crowds some nights have grown to tens of thousands. Several thousand had congregated at the site by midday Friday.

A more limited move would be for troops to take tougher action against any sign of Morsi supporters engaged in violence. Some Islamist protesters have been seen with weapons -- though their opponents have been as well, and each accuses the other of sparking clashes. Another possibility is that the military would detain Brotherhood and other Islamist leaders who already face arrest warrants, including Badie.

On Thursday, military spokesman Col. Ahmed Mohammed Ali said el-Sissi's call was "not a threat to any specific political group." He said the military respects peaceful protests.

But he said any violence or terrorism will be "dealt with decisively and with force" -- signaling a likely tough approach on any sign of violence, which Islamists' opponents have largely blamed on the pro-Morsi camp.

He said a national reconciliation conference and a system of transitional justice, called for by military-backed interim President Adly Mansour, are the only way out of Egypt's current standoff.