Libya's prime minister has convinced the defence minister not to resign, just hours after Mohammed al-Barghathi said he was quitting in protest against the siege of two government ministries by armed groups, the premier's spokeswoman said.

"The prime minister asked the defence minister to change his mind and to consider the situation the country is in, and so he decided to change his mind," the spokeswoman told Reuters news agency on Tuesday.

Barghathi resigned earlier in the day, calling a siege of government ministries by armed groups an "assault" on democracy.

His came as armed men in Libya's capital, Tripoli, kept up their siege of ministries on Tuesday despite parliament's adoption of a law to purge Gaddafi-era officials from their posts, which was supposed to appease the protesters.

"I will never be able to accept that politics [can] be practised by the power of weapons ... This is an assault against the democracy I have sworn to protect," Barghathi said.

He would have been the first cabinet minister to quit in a crisis over the siege.

Al Jazeera's Mahmoud Abdelwahad, reporting from Tripoli, quoted Barghathi as indicating that "he can't be a part of this, either by being silent and taking no action, or by taking any action because he can't be part of the shedding of Libyan blood if he takes any action as a responsible official or as a minister of defence".

Some polticians are demanding the government's resignation.

Siege of ministries

Libya's parliament voted on Sunday to ban anyone who held a senior position during Muammar Gaddafi's 42-year rule from government, a move which could also unseat the prime minister and other top officials regardless of their part in toppling the long-time ruler.

Politicians debated the draft law for months, but the issue came to a head this week when heavily armed groups took control of two ministries and stormed other institutions including the state broadcaster.

Many say the decision to hold the vote under duress could embolden the armed groups to use force again to assert their will over parliament.

Members of parliament in Libya, plagued by armed disorder since Gaddafi's demise, say the new legislation could be applied to around 40 of 200 deputies and could also unseat the prime minister, who some protesters demand should quit immediately.

'Damning indictment'

A spokesman for parliament conceded on Monday that the siege of the ministries was out of the government's hands and that it would be up to the militiamen now to leave as promised.

Feraj Najem, a Tripoli-based political analyst, told Al Jazeera that Barghathi's resignation would have been a "damning indictment of the political process."

"This is a minister who could not protect his own ministry, yet some of those militiamen who are surrounding these ministries are wearing military uniforms - Barghathi 's ministry's uniforms," Najem said.

"So they are sending the wrong signal. He's a man who is trying to organise the army, but apparently part of this army is rebelling."

He said that the government is under a great deal of pressure due to the behaviour of "these militiamen, which is the least to say about them - they are outlaws".