Hundreds of thousands of Egyptians took to the streets on Friday in rival mass rallies for and against the army's overthrow of Islamist president Mohamed Mursi, who state media said was under investigation for charges including murder.
Five people were killed and more than 50 injured during fighting in the second city of Alexandria. A total of more than 200 were hurt in scattered confrontations nationwide, the health ministry said, with fears of more bloodshed as night fell.
In Cairo, huge crowds heeded a call by army chief General Abdel Fattah al-Sisi to give him a popular mandate to confront violence unleashed by his July 3 overthrow of Mursi.
Sisi's call, and news of the investigation, signaled a major stepping up of the military's confrontation with Mursi's Muslim Brotherhood movement.
The army's move against Egypt's first freely-elected president has caused alarm in the West. The country of 84 million people forms a bridge between the Middle East and North Africa and receives $1.5 billion a year in mainly military aid from the United States.
Supporters of Mursi staged mass counter-demonstrations to demand his reinstatement, shrugging off fears of an imminent crackdown.
In Alexandria on the Mediterranean coast, a Reuters reporter said hundreds of people fought a pitched battle, with birdshot fired and men on rooftops throwing stones at the crowds below.
In Cairo, fireworks lit up the night sky over the central Tahrir Square, packed by army supporters in jubilant mood.
In a sign of Sisi's rising political star, many clutched posters of the general in uniform, some depicting him alongside former military officers who became Egyptian presidents, Gamal Abdel Nasser and Anwar Sadat.
"The Brothers stole our revolution," said Salah Saleh, a horse trainer at a central Cairo rally, voicing widespread criticism that Mursi refused to share out power after taking office, and then failed to tackle Egypt's many problems.
"They came and sat on the throne and controlled everything."
Clashes have frequently broken out after dark during weeks of turmoil in which close to 200 people have died, many of them Brotherhood supporters.
The army has signaled it intends to get tough with the Islamists, who have staged a month-long tent vigil in Cairo.
The Brotherhood emerged from decades in the shadows to win successive elections after Egypt's 2011 Arab Spring uprising against veteran autocrat Hosni Mubarak. It lasted a year in government, during which the economy floundered and Mursi's popularity slumped, before the army shunted it aside on the back of huge protests.
Many thousands of men, women and children joined Brotherhood supporters at their round-the-clock vigil in northeast Cairo, which is close to army installations but far from Tahrir Square, focal point for the pro-army rally.
"It is either victory over the coup or martyrdom," senior Brotherhood politician Mohamed El-Beltagy told the pro-Mursi rally. "Our blood and our souls for Islam!" the crowds chanted.
The military had warned it would "turn its guns" on those who used violence. The Brotherhood warned of civil war, accusing the army and hired thugs of stoking trouble to justify a move against the Islamists.
In Cairo, helicopters repeatedly buzzed low over the pro-Mursi vigil before wheeling around Tahrir Square, and scattering Egyptian flags over the packed supporters.
"The Muslim Brotherhood has deviated from the path of real Islam," said Gamal Khalil, a 47-year-old taxi driver as his wife and two daughters waved flags at passing cars on a bridge over the Nile. "The army is the only honest institution in the country," he said. "They're keeping my whole family safe."
The investigation into Mursi centers on accusations that he conspired with the Palestinian Islamist group Hamas to escape from jail during the 2011 uprising, killing some prisoners and officers, kidnapping soldiers and torching buildings.
Mursi has previously said local people helped him to escape during the upheavals, and the Muslim Brotherhood denounced the series of accusations leveled against him. Hamas challenged investigators to find "one piece of evidence" that it had meddled in Egyptian affairs.
"At the end of the day, we know all of these charges are nothing more than the fantasy of a few army generals and a military dictatorship," Brotherhood spokesman Gehad El-Haddad said. "We are continuing our protests on the streets."
State news agency Mena said Mursi, who has been held incommunicado since his overthrow, had been ordered to be detained for 15 days pending the inquiry.
Convulsed by political and economic turmoil, Egypt is polarized, struggling to make the transition from the autocratic rule of Mubarak to a free and open democracy.
Signaling its displeasure at recent events, Washington said this week it had delayed delivery of four F-16 military jets to Cairo and called on the army to exercise "maximum restraint and caution" during Friday's rallies.
One security source said the military wanted to calm the situation after realizing that Sisi's call to rally was not well received abroad. A military statement on Facebook said the protests did not represent a threat to the Brotherhood.
State television screened images on Friday of the celebrations that erupted the night Sisi announced Mursi had been deposed. The narrator declared it "the day of liberation from the Brotherhood occupation".
"Egypt against terrorism," declared a slogan on the screen.
The army has appointed an interim government tasked with preparing for parliamentary elections in about six months followed by a new presidential vote. The Brotherhood says it will not join the process.
The turmoil has further hurt a battered economy and tourist industry. Hisham Zaazou, Tourism Minister in the interim cabinet, said his ministry would stage a laser show on the pyramids on Saturday, displaying the slogan "Pharoahs against violence".