People assist a man who was injured Friday after Libyan militiamen opened fire on a crowd that wanted them to move out of the capital, Tripoli. Mahmud Turkia/AFP/Getty Images

At least 27 people have been killed and 235 wounded after gunmen opened fire Friday on protesters who had called on armed groups to leave Tripoli. The latest violence further challenges Libya's weak central government.

"The demonstration was peaceful and had been permitted by the Interior Ministry, and then the protesters were fired on when they entered the Gharghur district," where the militia's headquarters are located, Prime Minister Ali Zeidan said in a TV interview Friday.

"The existence of weapons outside the army and police is dangerous," Zeidan added. "All armed militias need to leave Tripoli, without exception."

The third outbreak of street fighting within 10 days underscored Libya's struggle to contain regional militias that helped overthrow leader Muammar Gaddafi two years ago but kept their guns. Armed disorder has blocked most oil exports for months.

Friday's bloodshed, the worst in Tripoli for several months, began when militiamen opened fire, first into the air and then into hundreds of protesters who were demanding their eviction from the capital after the militias had repeatedly battled with other armed factions for control of certain neighborhoods.

A Reuters reporter saw an anti-aircraft cannon firing from the militia compound into the crowd as it chanted: "We don't want armed militias!"

Demonstrators at first fled but then returned, heavily armed, to storm the gated buildings, where militiamen from the central coastal town of Misrata were holed up past nightfall.

Dozens of soldiers in army trucks came to try to separate the crowds and militiamen in the compound, sealing off roads to prevent more armed people from joining the unrest.

Heavy smoke could be seen rising from the scene.

Air force planes circled overhead to monitor Tripoli's main roads. "We want to make sure the militia don't bring in any reinforcements," said army spokesman Ali al-Sheikhi.