The Libyan prime minister's kidnapping by ex-rebel militiamen on Thursday underlined the state's impotence faced with a myriad of armed groups which in theory take their orders from the authorities.

Gunmen snatched Ali Zeidan from the Tripoli hotel which for security reasons has served as his residence for the past several months, before he was freed several hours later.

His bodyguards, part of Libya's security forces which lack discipline and training, were apparently taken by surprise.

Combat-hardened militias have filled the security void in Libya since a 2011 conflict which overthrew longtime dictator Moamer Kadhafi, sweeping away his regime and state institutions.

The transitional authorities have entrusted Kadhafi's former foes with the task of border control and the running of prisons and strategic installations, granting legitimacy and a sense of impunity to the militias.

They have also been accorded privileges and funding, along with the armaments which they inherited from the 2011 conflict, putting them in a position to control smuggling and racketeering.

With a variety of political agendas and motives, the militias refuse to disarm and have snubbed several plans drawn up by Zeidan's government to be integrated into a new army and police force.

Their argument has been that the revolution is not over and they need to hold onto their arms until its goals have been achieved.

In March, the General National Congress, Libya's top political authority, ordered the withdrawal of all gunmen from the streets of Tripoli, but to no effect.

With authorities struggling to set up new security forces, the militias impose their will through the use of arms, such as in April when they forced legislation through parliament blacklisting Kadhafi-era officials.

State authorities face a dilemma: resorting to force with all the inherent risks in an unstable country or holding negotiations which could be interpreted as a sign of weakness.

After an initial spell of talking tough, Zeidan has had to tone down his attacks and explain "there are no militias in Libya," just "thowars," the revolutionaries who toppled Kadhafi with NATO air support.

His government has repeatedly stressed its priority is to protect lives, especially in a society where tribal loyalties run deep and a single death could spark a bloody vendetta.

A former interior minister who resigned, Ashur Shawayel, said in a recent television interview that this was an admission of weakness on the part of the authorities who had no stomach to take on the militias.

The militias, on the other hand, resort to military action each time they see their interests at risk.

"Zeidan's kidnapping proves the decay of the Libyan state ... It's those bearing arms in the name of certain ideologies who really govern this country," said a Libyan analyst, asking not to be named.

Another analyst, Khaled al-Fadhli, warned that Libya could slide into civil war and "terrorist acts of revenge by Al-Qaeda" in the absence of "a serious and transparent dialogue to reach a democratic transition."

The pre-dawn seizure of Zeidan came five days after US commandos embarrassed and angered Libya's government by capturing senior Al-Qaeda suspect Abu Anas al-Libi off the streets of Tripoli.

"The fact that the (US) mission was a success reveals the permissiveness of the Libyan environment and the absence" of the government, said Geoff D. Porter of North Africa Risk Consulting.

"Even in the capital itself, there are very few deterrents to doing almost anything, whether it is criminality, political violence, political activism, or in this case, a cross-border counter-terrorism raid."