CAIRO — Egyptian authorities escalated their battle against ousted president Mohamed Morsi and his supporters Friday, launching an investigation into espionage and murder allegations against him as millions took to the streets in rival demonstrations across the country.

The allegations marked the state’s first legal steps against Morsi, who has been held incommunicado since he was deposed this month in a military coup. The steps were taken as the military supervised mass rallies in Cairo that it had called to back its “mandate” to confront violence and “terrorism” — words that rights groups and Morsi’s supporters interpreted as signaling an imminent crackdown. While the demonstrations were mostly peaceful, deadly clashes broke out in the coastal city of Alexandria and early Saturday in Cairo.

Security forces attacked the Brotherhood’s sprawling sit-in outside the Rabaa al-Adawiya mosque in eastern Cairo at about 3 a.m. Saturday, firing barrages of tear gas and live ammunition, killing eight and injuring hundreds of others, the group said. The al-Jazeera television network aired footage showing rows of ambulances moving through hectic crowds of Morsi supporters in eastern Cairo.

On Friday evening, Egypt’s interior minister and interim president had warned in phone calls to the al-Hayat television station that the pro-Morsi demonstrations would soon be forcibly shut down.

“These sit-ins will be ended soon, within the limits of the law,” Interior Minister Mohamed Ibrahim told the channel.

“We cannot accept this security chaos, and the road blocking, and the bridge blocking,” interim president Adly Mansour said in a separate call. “We can’t accept the attacks on the public property. he state has to enforce its sovereignty.” He urged Morsi’s supporters to “go back to your homes” — saying that if they did, “no one will pursue you.”

In the coming days, he said, Egyptians will see that “terrorism is in decline,” for the state will deal with it with “all strictness.”

Earlier Friday, judicial authorities announced prosecutors are investigating allegations that Morsi conspired with the militant Palestinian Islamist organization Hamas in a 2011 prison break that freed him and about 30 other Muslim Brotherhood members amid the chaos of the Arab Spring uprising that toppled Hosni Mubarak.

The allegations also include murder and kidnapping in connection with the prison break northwest of Cairo, in which prosecutors say Hamas gunmen attacked the facility at the behest of Morsi and the Brotherhood, killing 14 guards.

The Brotherhood and Hamas separately denied the allegations. The Brotherhood said local residents carried out the attack to free their relatives.

The judicial announcement was the first official comment on Morsi’s legal status since he was ousted, and his supporters, who gathered by the hundreds of thousands in Cairo and Alexandria on Friday, quickly dismissed the allegations as political.

“The charges are nothing more than an attempt by the coup leaders to discourage the public from supporting the president’s legitimacy,” said Alaa Abdel-Aziz, who served as Morsi’s culture minister until he and other Islamist and Brotherhood cabinet members were ousted on the day of the coup.

The notion that Egypt’s elected president had worked “as a spy for Hamas” is a “silly accusation,” he said. “These are old tactics. They remind me of the ’50s and ’60s,” he added, referring to the military rule of Gamal Abdel Nasser, under which the Muslim Brotherhood was brutally repressed.

Pro-Morsi demonstrators first came under attack Friday in Alexandria when plainclothes men broke through their protest lines, assaulting them with rocks and rubber bullets, witnesses said.

Amr Nasr, the head of the ambulance services in Alexandria, said five people were killed and 140 injured in clashes in the city Friday. The Muslim Brotherhood said more than 300 people were injured.

A spokeswoman for the Brotherhood-led Anti-Coup, Pro-Democracy Alliance said that the attack came in two waves and that the men who descended on the pro-Morsi demonstrators included uniformed police officers.

The protesters were kneeling to pray when “thugs attacked,” said the spokeswoman, Farida Mustafa. “Later, after the prayer, police officers alongside thugs attacked the protesters with live bullets, rubber bullets and tear gas.”

Video footage posted online showed bloodied Morsi supporters being treated at a makeshift hospital for head wounds and shotgun-pellet wounds across their torsos.

The chief of Egypt’s armed forces, Gen. Abdel Fatah al-Sissi, had called on Egyptians to take to the streets Friday to grant the military the authority to combat “terrorists” — a label that it has sought to attach to Morsi’s Islamist supporters in the Muslim Brotherhood.

State and independent media have echoed that portrayal with growing fervor in recent weeks, casting the coup as a “revolution” against extremists. And several television stations and newspaper front pages urged Egyptians to turn out Friday to support the military.

Armored vehicles and troops guarded the entrances to Cairo’s Tahrir Square and deployed outside the presidential palace, where hundreds of thousands of pro-military demonstrators rallied. Many of them hoisted Sissi’s picture aloft. Military helicopters flew low over the square as their pilots waved, eliciting cheers from the crowd. Security forces provided no protection for Morsi’s supporters, who also gathered in the hundreds of thousands across town.

Security forces have rounded up hundreds of Brotherhood members in the past three weeks, including a number of Morsi’s top aides, who also have been held incommunicado. Prosecutors have issued arrest warrants for the Muslim Brotherhood’s supreme guide and other top officials, who have sought refuge amid the group’s continuing protest outside Rabaa al-Adawiya.

The military’s actions have echoed those of Mubarak, who ruled with an iron fist for 30 years and led frequent crackdowns against the Muslim Brotherhood and other political opponents.

Outside Rabaa al-Adawiya, pro-Morsi demonstrators handed out petitions Friday headlined by the word “Reject” and modeled after a campaign by the anti-Morsi Tamarod — or “rebel” movement — that preceded Morsi’s ouster. The petitions offered Morsi’s supporters the chance to declare their rejection of the military’s coup, of “any unelected president” and of the country’s “return to the age of oppression and humiliation.”

The investigation of Morsi and his role in the prison break focuses on the tumultuous days of Egypt’s 2011 revolution. Thousands of political prisoners, including secular activists and Islamists such as Morsi, were detained before and during the 18-day popular uprising that unseated Mubarak. Many were released or escaped amid the protests and clashes in January and February 2011 as Mubarak’s security forces receded across the country and the military took control.

Hamas, the Palestinian militant group that controls the Gaza Strip, rejected accusations of its involvement in the jailbreak as an attempt to drag it into the Egyptian conflict. The group called on the Arab League to oppose such “incitement” against it.

Egyptian security officials and local media have accused Palestinians and other foreigners of stoking violence in Egypt since Morsi’s ouster, particularly in the volatile Sinai Peninsula, which borders Gaza.

Morsi was formally ordered detained for 15 days. He has been held in an undisclosed location since the July 3 coup and has been denied access to his attorney, his family and human rights groups, Brotherhood officials said.

William Booth in Jerusalem contributed to this report.

Abigail Hauslohner covers transportation and development for The Washington Post. Previously, she served as the Post’s Cairo bureau chief.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.

To pause and restart automatic updates, click "Live" or "Paused". If paused, you'll be notified of the number of additional comments that have come in.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.