Hundreds of protesters have stormed the headquarters of Islamist militia groups in the eastern Libyan city of Benghazi and evicted fighters from several sites.

At least four people were killed and dozens of others were injured when militiamen opened fire as they defended one of the bases.

Looters carried weapons out of the vacated Ansar al-Sharia military base compound, which has been linked to the attack on the US consulate last week.

The US ambassador to Libya and three other Americans died in the attack.

Ansar al-Sharia has denied any involvement.

The action against the group appeared to be part of a coordinated sweep of militia headquarters buildings by police, government troops and activists following a mass public demonstration against militia units yesterday.

As protesters left Ansar al-Sharia's headquarters, the crowd swelled, reaching thousands as it headed toward its 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.

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

Yesterday’s "Rescue Benghazi day" demonstration called for the government to disband armed groups that have refused to give up their weapons since the NATO-backed revolution last year.

Although the main demands of the marchers did not mention the attack on the US consulate, it seems to have provided a strong impetus for the authorities to rally support behind the country's weak government.

US Ambassador Christopher Stevens was well liked and many Libyans condemned the attack on the consulate despite being angered by the anti-Islamic US-made film that triggered it.

Benghazi is controlled by various armed groups, including some comprised of Islamists who openly proclaim their hostility to democratic government and the West.

Some are identified by local people as being among those who were at the consulate protest last week. US officials have described the violence as a "terrorist attack."