Heavy gunfire erupted amid a tense standoff in central Cairo on Saturday, as security forces and an angry mob surrounded a mosque where hundreds of anti- government protesters had taken refuge, a day after widespread violence left at least 230 people dead nationwide and deepened fears of a slide toward full-blown civil conflict.

In the early afternoon, before gunfire broke out, soldiers negotiated a safe exit for some of those trapped inside the al-Fateh mosque in Ramses Square, escorting them past a mob of civilians eager to attack them. By late afternoon, following what appeared to be a protracted exchange of gunfire, security forces said they were able to enter the mosque to clear it.

At the height of the standoff, footage broadcast on state television showed troops in armored vehicles and exchanging fire with gunmen in the minaret of the mosque where many of those wounded in the violence on Friday were being treated, along with people who had fled the gunfire the day before.

Footage aired later showed police officers moving into the mosque and around its main hall, aiming their weapons. It was unclear what had happened to the dozens of people remaining inside.

The previous day, armed vigilantes known as Popular Committees had joined police and army troops in seeking to quell demonstrations by the Muslim Brotherhood. Brotherhood members and other Egyptians who say they oppose the military’s July 3 coup were protesting a brutal crackdown Wednesday on the movement’s two sit-ins set up to call for the reinstatement of deposed president Mohamed Morsi.

Violence across the country Wednesday left more than 600 people dead.

Egypt’s government put Friday’s death toll at 173, in addition to 57 members of the police, and said it was considering measures to outlaw the Brotherhood. Government spokesman Sherif Shawky blamed the Brotherhood for the violence, calling the demonstrations “the furthest thing possible from peaceful.”

“Eighty percent of nationwide deaths were caused by the Brotherhood using weapons to attack citizens and police,” he added. “The police used the highest levels of self-restraint.”

The Brotherhood has, however, accused the security forces of opening fire on unarmed demonstrators, as Friday’s protests, billed by the group as a Day of Rage, turned into a frightening glimpse of what may lie ahead for the deeply polarized country.

The United States and European countries have grown increasingly critical of Egypt’s actions, threatening to cut aid and reevaluate their ties to the Arab world’s largest state. On Saturday, Qatar condemned what it called “the excessive use of force” in the suppression of the protests, and urged Egyptian authorities to embark on dialogue.

“One of the main concerns of Qatar is that what is happening will divert democracy in Egypt,” said Foreign Minister Khalid bin Mohammad al-Attiyah while on a visit to Germany.

The comments put Qatar, the Morsi government’s staunchest foreign backer, at odds with Saudi Arabia, which has expressed wholehearted support for the crackdown. Speaking alongside Attiyah, Germany’s foreign minister, Guido Westerwelle, warned of a “a great danger that more blood will spill . . . which indicates the danger of civil war.”

Protester camps in Cairo

In a defiant news conference Saturday aimed at the international community, Egypt’s presidency defended the government’s actions, saying the state was engaged in a war against terrorism.

“This state and this people are now under attack,” said Mostafa Hegazy, an adviser to interim President Adly Mansour. He said the state and its security forces remained committed to defeating the “terrorists” and implementing the political road map laid out by Egypt’s military after it wrested control from Morsi last month.

“We will triumph simply for the reason that Egyptians have never been more united than they are today,” Hegazy said.

But those on Egypt’s streets Saturday were anything but united.

On Saturday morning, soldiers began to escort small groups of mostly women out of the al-Fateh mosque, where dozens of pro-Morsi protesters had barricaded themselves since Friday, after coming under attack by Egyptian security forces and anti-Morsi demonstrators.

But bystanders and people who had sought cover in the mosque said the escape was limited: Both those trying to flee and the troops escorting them had to navigate through an angry mob of civilians, many of whom said they wanted to “get to” the “terrorists” inside. Some carried sticks and knives.

“The Muslim Brotherhood is inside, and the people are outside, trying to get in,” said Adel, a paramedic who stood by with an ambulance team and gave only his first name to avoid harassment in the deeply tense atmosphere.

At one point, the mob identified a man they thought was a member of the Muslim Brotherhood inside a nearby apartment building. They tried to storm the building to lynch him; soldiers held them back. Others in the crowd said a woman named Shaimaa inside the mosque had spoken to al-Jazeera and spread “lies”; they wanted to get her, too.

“The military is not able to deal with the situation because of the crowd. Every person they try to get out, you’ll find 600 others trying to get to him,” said Mohamed Gadalla, a bystander.

Ali Ibrahim, a furniture maker from the neighborhood and part of the crowd trying to enter the mosque, said he had helped capture a man with “a big beard” and had “delivered” him into military custody. As he spoke, a crowd of young plainclothes men ran along one wall of the mosque, apparently looking for a way around the barricades.

Hani Nawara, a former assistant to the minister of health under Morsi, was one of the people who had taken refuge in the mosque overnight and managed to get out Saturday afternoon.

Soldiers escorted Nawara and another doctor out, he said. But the only reason they made it past the mob alive was because “we didn’t have beards,” Nawara said. Others were less lucky, he said, arrested promptly by the military, or worse.

As gunfire erupted around the mosque, minutes after Nawara exited, civilian bystanders fled into nearby side streets and alleys, tripping over one another and pressing themselves against walls in an effort to find safety.

It was unclear who started the gun battle, but tear gas quickly drifted through side streets, and television footage showed police and military opening fire on the mosque. Tufts of white smoke were visible at the top of the mosque’s minaret, indicating that someone there was also firing a gun.

As the sounds of gunfire rattled through the neighborhood and tear gas struck the mosque, some of those fleeing the scene appeared to be trying to escape not just the gunfire, but also the mob.

At one point, plainclothes men caught up with a bearded man who was running and already bleeding heavily from the head. They grabbed him and beat him more.

The Muslim Brotherhood’s Freedom and Justice Party reported on its Web site Saturday that the son of Mohammed Badie, the Brotherhood’s supreme guide, had been shot dead in Ramses Square during Friday’s clashes. The Egypt Independent, an English-language news Web site, also said that Badie’s family home in the southern town of Beni Suef was “searched” Friday night and then set ablaze.

Prime Minister Hazem Beblawi also defended the government’s crackdown on the Brotherhood protests.

“Despite everything on Wednesday, I say it represents a good achievement,” Beblawi said Saturday in a brief interview aired on state television.

“We want reconciliation,” he said. “But there cannot be reconciliation with those whose hands are tainted with blood. There will be no reconciliation with those who have borne arms against their brothers, those who have disregarded the law.”

State TV reported Saturday night that “all protesters have exited al-Fateh mosque and the crisis is over.” But even as footage aired of the eerily deserted area around the mosque, protesters elsewhere spilled onto the streets after evening prayers, defying the nighttime curfew to stage fresh demonstrations against the bloodshed.

Al-Jazeera broadcast live footage of thousands of people marching through the streets and chanting against the government in the northern city of Alexandria and in Minya, a city 150 miles south of Cairo that has been the scene of a number of attacks on churches in recent days.

State media also reported attacks on security forces in an industrial suburb north of Cairo and in the city of Suez on Egypt’s vital canal Saturday. In the southern city of Assiut alone, security forces detained 72 Morsi supporters, the state-run al-Ahram newspaper reported. The city has long been a bastion of Islamist support.

In defiance of the security crackdown and Friday’s large death toll in Ramses Square, the Brotherhood-led Anti-Coup Alliance has called on its supporters to continue marching on the square every day for the next week, vowing that protesters will perform their evening prayer there.

Amer Shakhatreh and Lara El Gibaly contributed to this report.