The violence is the latest episode in more than a year of turmoil in Egypt following the ouster of longtime authoritarian ruler Hosni Mubarak and will likely fuel more tensions just three weeks ahead of presidential elections.
The military generals who took over from Mubarak in February last year have promised to hand over power to a civilian administration by July 1 but that has not stopped rallies demanding the generals leave immediately.
The security officials said the clashes broke out at dawn when the assailants set upon several hundred protesters who had camped out in the area since early Saturday to press their demand for the military to go. The protesters fought back and the Health Ministry said that by noon, nine people were killed and 49 were injured.
It was not clear if the victims were all protesters or if any of the attackers were among the dead. It was also not clear who the attackers were. The clashes resumed later in the morning, after a few hours' lull, but then stopped again when lines of black-clad riot police and army troops backed by armoured vehicles moved in to separate the two sides at noon Wednesday.
Most of the protesters were supporters of Hazem Salah Abu Ismail, an ultraconservative Islamist who was thrown out of the presidential race because his mother held dual Egyptian-U.S. citizenship, which violates eligibility rules for running in the election.
The officials said rocks, clubs and firebombs were used in the clashes. Witnesses reported hearing gunshots during the fighting, which lasted several hours. Video footage broadcast on regional television channels showed pitched battles between the two sides on residential streets close to the Defence Ministry in the Cairo district of Abbasiyah.
The rattle of gunshots could be heard in the footage and bearded Abu Ismail supporters chanting "Allahu Akbar," or "God is Great" in Arabic, as others pelted their attackers with rocks. It was not clear who was shooting. Some of the protesters carried clubs, while many wore hard hats to protect their heads from flying rocks.
The protest camp near the Defence Ministry began Saturday with only Abu Ismail supporters but they were later joined by die-hards from various pro-democracy groups. The protesters' number would swell to up to two or three thousands in the evenings but stayed around 1,000 during the days.
There have been unconfirmed media reports that some of the Abu Ismail supporters brought firearms to their encampment after an attack by assailants earlier this week that left one protester dead.
The security officials spoke on condition of anonymity because they were not authorized to speak to the media.
Troops and police deployed in the area around the Defence Ministry had not intervened in earlier attacks there and at first did nothing to stop the killings Wednesday, leaving the clashes to continue until noon when they moved in.
Since the weekend, Egypt's pro-military state media have said the assailants were residents angered by the disruption caused by the protests to life in their neighbourhood. But pro-democracy activists maintain the assailants operate with the blessing of the police or the military, and that they may even be on their payroll.
Wednesday's attack came hours after the protesters outside the Defence Ministry said they had caught an off-duty army officer who came to the area to look around, an act that must have been taken by the generals as an insult to the armed forces.