Angry protesters set fire to buildings at the Benghazi base of a militia blamed for the death of US ambassador Chris Stevens Reuters

Militias blamed for the killing of US ambassador Chris Stevens have been forced out of Libya's second city, Benghazi, by popular protests.

At least 11 people were killed and 60 wounded as militiamen tried to defend their compounds against thousands of demonstrators protesting against extremism.

Saturday morning's rout followed a day of demonstrations on Friday against the militias, in particular Ansar al-Sharia, which has been blamed for the murder of the US ambassador and three of his colleagues.

The action against Ansar al-Sharia appeared to be part of a co-ordinated sweep of militia headquarters buildings by police, government troops and activists after a mass public demonstration against militia units on Friday.

Demonstrators also attacked compounds belonging to pro-government militias which may have contributed to the casualties.

Looters carried weapons out of the vacated Ansar al-Sharia military base as men clapped and chanted: "Say to Ansar al-Sharia, Benghazi will be your inferno."

A spokesman for the group said they left Benghazi to preserve security.

Chanting "Libya, Libya", "No more al-Qaida" and "The blood we shed for freedom shall not go in vain" hundreds of men waving swords and even a meat cleaver stormed Ansar al-Sharia's headquarters.

"After what happened at the American consulate, the people of Benghazi had enough of the extremists," one demonstrator, Hassan Ahmed, said. "They did not give allegiance to the army. So the people broke in and they fled."

Demonstrators pulled down militia flags and set a vehicle on fire inside what was once the base of former leader Muammar Gaddafi's security forces, who tried to put down the first protests that sparked last year's uprising.

"This place is like the Bastille. This is where Gaddafi controlled Libya from, and then Ansar al-Sharia took it over. This is a turning point for the people of Benghazi," said Ahmed.

Adusalam al-Tarhouni, a government worker who arrived with the first wave of protesters, said several pickup trucks with the group's fighters had initially confronted the protesters and opened fire. Two protesters were shot in the leg, he said.

"After that they got into their trucks and drove away," he said. Protesters had freed four prisoners found inside, he said.

As protesters left Ansar al-Sharia's headquarters, the crowd swelled, reaching thousands as it headed toward the Islamists' military base, which was shared with another militia group.

Protesters said the militiamen opened fire as they arrived and several people were wounded.

After the crowd entered that compound, Libyan army trucks sped away from the base carrying government troops cheering in victory and crying out: "God is greatest."

Vigilantes armed with machetes and clubs blocked the road leading away from the compound, stopping cars to prevent looters from driving off with heavy weapons.

"We went into the camp and we didn't find anyone. We just took these Kalashnikovs," said one youth, holding rifles.

The demonstrators also took over a compound belonging to the Abu Slim brigade and another Ansar al-Sharia compound.

The apparent defeat of Ansar al-Sharia across Benghazi and the huge outpouring of public support for the government marks an extraordinary transformation in a country where the authorities had seemed largely powerless to curb the influence of militia groups armed with heavy weapons.

Nevertheless, Ansar al-Sharia and other Islamist militia have bases elsewhere in eastern Libya, notably around the coastal city of Derna, known across the region as a major recruitment centre for fighters who joined the wars in Iraq, Afghanistan and Syria.