Hundreds of Libyan pro-democracy advocates have come under attack by supporters of a law to exclude Gaddafi-era officials from top government jobs, in the latest sign of the turmoil that threatens the country's first elected authorities.

Several hundred people gathered in Tripoli's central Algeria Square on Friday to protest against armed groups that have been laying siege to the justice and foreign ministries to call for the sacking of officials from the ousted regime of Muammar Gaddafi.

Protesters waved placards reading "The era of the militias is over" and "Attacks on the ministries are attacks on the Libyan people" as well as "No to weapons, yes to dialogue."

The crowd marched to Martyrs' Square where they were attacked by demonstrators calling for the adoption of the law to exclude Gaddafi-era officials from top government posts, although no one was hurt.

The main demonstration then left the square for the prime minister's office to "express Tripolitans' solidarity with the government and the legitimate authorities in the country," an organiser said.

Libya's army had taken up positions earlier on Friday at strategic sites around the capital, and soldiers in pickup trucks mounted with machineguns were also deployed on Martyrs' Square ahead of the protests.

Examining the bill

Gunmen in Tripoli have encircled the foreign ministry since Sunday and the justice ministry since Tuesday, to demand that the General National Congress (GNC) adopt a bill that would purge former officials of the ousted regime.

The same groups, most of them former rebels who fought to oust Gaddafi in 2011, briefly occupied the finance ministry on Monday.

The GNC, Libya's highest political authority, has been studying proposals for a law that would see top figures from the former regime removed from their posts.

That has caused a stir among Libya's political elite, as several current senior officials could be affected.

Under increasing pressure from demonstrators, the GNC said on Monday that it was suspending plenary sessions until Sunday.

It said the delay was needed to give political blocs in the GNC time to examine the bill to reach a compromise on the law.

GNC Vice President Salah al-Makhzoum said a compromise had been reached among the political blocs by adding "exceptions" in the bill in order to retain key individuals.

He said the bill is expected to be voted on next week.