Libya's General National Congress, under pressure from militiamen, on Sunday voted through a controversial law to exclude former regime officials from government posts, a move that could see the premier removed from office.
Gunmen who had surrounded the foreign and justice ministries to press for officials from the dictator Moamer Kadhafi's regime who hold top government jobs to be sacked welcomed the vote and lifted their siege.
State television broadcast live coverage showing 164 lawmakers in the 200-member GNC vote in favour of the law with just four deputies present voting against.
Under the law, all those who held key official posts from September 1, 1969 when Kadhafi took power, until the fall of his regime in October 2011 will be excluded from government, but it was not immediately clear for how long.
An earlier draft bill seen by AFP said the ban would last five years, but later GNC sources said it could be up to 10 years before it is lifted.
The proposal for the law caused a stir among Libya's political elite, as senior members of the government could be affected, including Prime Minister Ali Zeidan and GNC president Mohamed Megaryef.
Both were diplomats under Kadhafi before joining the opposition in exile.
Fifteen lawmakers also risk loosing their jobs once the GNC's legal commission ratifies the law, including the vice president of the national assembly Jomaa Atiga, an official said.
"It is too early to speak of excluding Mr Megaryef. The situation will be clearer in a week or 10 days," a source close to the GNC president told AFP.
He suggested there could be some "amendments" to the law.
Megaryef, who was ambassador to India in the 1980s, was not present for the vote and sent the GNC a letter saying he would stay away to avoid "embarrassing" the lawmakers as they cast their ballots.
A special commission will now be set up to implement the new law which also affects former government ministers, ambassadors, security officers as well as state media officials, public university professors and union leaders.
The gunmen, many former rebels who helped topple Kadhafi, had encircled the foreign ministry for a week and the justice ministry since Tuesday to pressure the national assembly to pass the law.
They vowed to stand their ground and expand their action unless their demands were satisfied, and warned against any GNC attempt to make exceptions to allow key individuals to keep their jobs.
Vice president Salah al-Makhzum said last week that a compromise had been reached among the political blocs by adding "exceptions" in the bill in order to retain key individuals.
Before Sunday's vote the GNC, Libya's national assembly and top political body, had debated the law several times without reaching an agreement.
The bill proved particularly controversial with the National Forces Alliance, the liberal coalition that dominated elections in July, who feared it was aimed at their leader Mahmud Jibril who headed an economic council under Kadhafi.
Human Rights Watch had warned the GNC against a hasty vote.
"The GNC should not allow itself to be railroaded into making very bad laws because groups of armed men are demanding it," Sarah Leah Whitson, Middle East and North Africa director at HRW, said in a statement on Saturday.
"Libya's long-term prospects for peace and security will be seriously diminished if the congress agrees to nod through this law."
In April, under pressure from supporters of the law, the GNC made an amendment to the provisional constitutional declaration exempting the law from judicial review even before it was voted on.
Zeidan said on Saturday that the government preferred using "patience" and dialogue over force to resolve the sieges amid criticism by many Libyans who accuse the authorities of being too soft on the rebels.
Since the fall of Kadhafi's regime, militia groups, mostly ex-rebels, have managed border controls, prisons, strategic facilities and vital institutions.
They received salaries and other perks from the authorities, in addition to reportedly benefiting from smuggling and extortion.
Leaders of the ex-rebel militias said on Saturday the government had agreed to give five ministries over to their members.