The clash intensified as authorities said they were considering once again outlawing the 80-year-old Muslim Brotherhood, which led the government up until six weeks ago.
Local journalist Shaimaa Awad told The Associated Press that security forces on Saturday had rounded up protesters inside al-Fatah mosque, located in Cairo's central Ramses Square.
The sound of gunfire could be heard in the background.
The clashes came on the fourth day of bloodshed between the two sides, with the government saying 173 had died in the past 24 hours alone.
That brought the country's toll to more than 750 people since Wednesday, when 578 people were killed in nationwide clashes that erupted after police cleared two camps of Morsi loyalists in the capital.
The standoff at the mosque in central Ramses Square began on Friday, with security forces surrounding the building where Islamists were sheltering and trying to convince them to leave.
The official news agency MENA reported that gunmen opened fire on security forces from the mosque's minaret. Local television stations broadcast live footage of soldiers firing assault rifles at the minaret.
The mosque served as a field hospital and morgue following clashes on Friday in the area. The protesters barricaded themselves inside overnight out of fears of being beaten by vigilante mobs or being arrested by authorities.
The Muslim Brotherhood said that a son of its spiritual leader was among those killed in the fierce clashes on Friday.
The Brotherhood's political arm, the Freedom and Justice party, said that Mohammed Badie's son Ammar was killed during the "Day of Rage", ignited by anger at the violent clearance of two sit-in camps, leaving more than 600 people dead.
The Health Ministry said on Saturday that 95 people were killed in street violence in Cairo and around the country that accompanied Friday's demonstrations. Most deaths took place in central Cairo's Ramses square, a focal point of protests.
The Interior Ministry said that a total of 1,004 Brotherhood members were detained in raids across the country and that weapons, bombs and ammunition were confiscated with the detainees.
The Brotherhood-led anti-military coalition has called for a week of protests, further escalating unrest in the country.
The coalition says it won't back down until it topples the government installed by the military — which overthrew Morsi on July 3.
A post on the Facebook page of the army spokesman, Col Mohammed Ali, accused gunmen of firing from the al-Fatah mosque at nearby buildings, located at Ramses Square.
The upper floors of a commercial building towering over Ramses 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 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."
There were ongoing negotiations with the military to have protesters leave safely. State television showed small groups emerging from the mosque by late morning Saturday.
However, local journalist Shaimaa Awad trapped with the Islamists said talks failed after three women were detained by military after agreeing to get out early in the morning.