"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's 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.