CAIRO — Egyptian security forces stormed a Cairo mosque Saturday after a heavy exchange of gunfire with armed men shooting down from a minaret, rounding up hundreds of supporters of the country’s ousted president who had sought refuge there overnight after violent clashes killed 173 people.
The raid on the al-Fath mosque on Ramses Square was prompted by fears that deposed President Mohammed Morsi’s group, the Muslim Brotherhood, again planned to set up a sit-in, security officials said, similar to those that were broken up Wednesday in assaults that killed hundreds of people.
The arrest of the brother of al-Qaida chief Ayman al-Zawahri came in connection to the raid on the mosque. Officials said that he planned to bring in armed groups to provide support to those holed up inside the mosque.
Mohammed al-Zawahri, a Morsi ally, is the leader of the ultraconservative Jihadi Salafist group which espouses al-Qaida’s hardline ideology. He was detained at a checkpoint in Giza, the city across the Nile from Cairo, the official said.
The official spoke on condition of anonymity as he wasn’t authorized to brief journalists about the arrest.
The Egyptian government meanwhile announced it had begun deliberations on whether to ban the Brotherhood, a long-outlawed organization that swept to power in the country’s first democratic elections a year ago.
Such a ban — which authorities say is rooted in the group’s use of violence — would be a repeat to the historic and decades-long power struggle between the state and the Brotherhood.
For more than a month since the July 3 military overthrow of Morsi, Muslim Brotherhood members and supporters have attacked and torched scores of police stations and churches, in retaliation. Shops and houses of Christians have been targeted.
Such attacks spurred widespread public anger against the Brotherhood, giving the military-backed government popular backing to step up its campaign against the Islamist group. It reminded people of a decade-long Islamist insurgency against Mubarak’s rule in the 1990s which only strengthened security agencies and ended up with thousands of Islamic fundamentalists in prisons.
The assault on the al-Fath Mosque began Friday, as pro-Morsi protesters and armed men fled into the worship center to avoid angry vigilantes and arrest. They piled furniture in the mosque’s entrance to block authorities and enraged anti-Morsi protesters from reaching them.
The mosque served as a field hospital and an open-air morgue as a Brotherhood-called day of protests descended into violence. By daybreak Saturday, security forces and armored personnel carriers had surrounded the mosque and it appeared that military-led negotiations might defuse the standoff.
A post on the Facebook page of the army spokesman, Col. Mohammed Ali, accused gunmen of firing from the mosque at nearby buildings, located on Ramses Square in central Cairo. The upper floors of a commercial building and blood bank towering over the square caught fire during the mayhem, with flames engulfing it for hours.
A Muslim cleric, Sheik Abdel-Hafiz el-Maslami, told The Associated Press that people were afraid to leave the mosque out of fear of detention or being assaulted by the crowd outside. He said there were armed men inside the mosque at one point but protesters had forced them out.
‘‘We lost control over things,’’ the cleric said. ‘‘There were men with arms in the mosque who were forced out of the mosque but we can’t control things here.’’
He said there were ongoing negotiations with the military to enable the protesters to safely leave. State television showed small groups emerging from the mosque by late Saturday morning.
However, local journalist Shaimaa Awad who was trapped in the mosque with the Islamists said the talks failed after three women were detained by the military after agreeing to get out early Saturday morning.
An AP reporter said that thousands of anti-Islamist protesters rallied outside the mosque, chanting: ‘‘God take revenge on Morsi and those standing behind him!’’
Army tanks and soldiers closed off the main entrances to Ramses Square as soldiers sealed off the area with barbed wire.
By midday Saturday, gunmen took over a mosque minaret and opened fire on the security forces below, the state-run MENA news agency said. The crowd around the mosque panicked as soldiers opened fire with assault rifles, the chaos broadcast live on local television channels.
Several security officials told The Associated Press that ending the standoff at the mosque was essential after receiving information that the group planned to turn it into a new sit-in protest camp. They spoke on condition of anonymity in line with regulations.
On Wednesday, riot police, military helicopters, snipers and bulldozers broke up two sit-in protests in Cairo by Morsi supporters, leaving more than 600 people dead and thousands injured. That sparked days of violence that killed 173 people and injured 1,330 people on Friday alone, when the Brotherhood called for protests during a ‘‘Day of Rage,’’ Cabinet spokesman Sherif Shawki said.
Among those who died Friday was Ammar Badie, a son of the Brotherhood’s spiritual leader Mohammed Badie, the group’s political arm said in a statement.
Prime Minister Hazem el-Beblawi, who leads the military-backed government, later told journalists that authorities had no choice but to use force in the wake of recent violence.
‘‘I feel sorry for valuable blood shed,’’ el-Beblawi said. However, he cautioned that there will be no ‘‘reconciliation with those whose hands are stained with blood or those who hold weapons against the country’s institutions.’’
Signaling the Brotherhood’s precarious political position, Shawki said the government was considering ordering that the group be disbanded. The spokesman said the prime minister had assigned the Ministry of Social Solidarity to study the legal possibilities of dissolving the group. He didn’t elaborate.
Mustafa Hegazy, a political adviser to interim President Adly Mansour, told a press conference Saturday that the current Egyptian leadership is not in a ‘‘political dispute or difference’’ with the Brotherhood, instead, ‘‘we are in a war against treason and some sort of terrorism.’’
He added that Egyptians took to the streets on June 30 — the day that led to Morsi’s ouster — to revolt against ‘‘religious fascism.’’
The Muslim Brotherhood, founded in 1928, came to power a year ago when Morsi was elected in the country’s first free presidential elections. The election came after the overthrow of autocrat Hosni Mubarak in a popular uprising in 2011.
The fundamentalist group has been banned for most of its 85-year history and repeatedly subjected to crackdowns under Mubarak’s rule. While sometimes tolerated with its leaders allowed to be part of the political process, members regularly faced long bouts of imprisonment and arbitrary detentions.
Disbanding the group, experts say, would mean allowing security forces to have a zero-tolerance policy in dealing with the group’s street protests, as well as going after its funding sources. That could cripple the Brotherhood, though it likely wouldn’t mean an end to a group that existed underground for decades
The possible banning comes amid calls by pro-military political forces to brand the Brotherhood a ‘‘terrorist organization.’’
‘‘We are calling for declaring the Brotherhood as a terrorist group,’’ said Mohammed Abdel-Aziz, one of the leaders of the Tamarod youth movement that had organized mass rallies calling for Morsi’s ouster.
The military-backed government has declared a state of emergency and imposed a dusk-to-dawn curfew since Wednesday, empowering army troops to act as a law enforcement force. Top Brotherhood leaders, including Morsi, remain held on a variety of charges, including inciting violence.
Since Morsi was deposed in the popularly backed military coup, the Brotherhood has stepped up its confrontation with the new leadership, rallying thousands of supporters in sit-ins and vowing not to leave until Morsi is reinstated.
After security forces broke up the protest camps, Islamist supporters stormed and torched churches and police stations. In response, authorities authorized Egypt’s security forces to use deadly force against those attacking vital government institutions.
On Saturday, Egypt’s Interior Ministry said in a statement that a total of 1,004 Brotherhood members had been detained in raids across the country and that weapons, bombs and ammunition were confiscated from the detainees.
Several foreigners were also rounded up including Sudanese, Pakistanis and Syrians, the Internior Ministry said.
Morsi himself has been held incommunicado since his ouster. Top Brotherhood leaders including General Guide Deputy Khairat el-Shater were detained last month.