The killing of US ambassador Christopher Stevens two weeks ago, along with three other Americans, has prompted authorities in Libya to take action against the militias that stand as the country's most important security threat.

Made up of former rebels who fought against the Gaddafi regime - and many others who joined when the war was finished - these organisations number into the mid to low hundreds.

While many have shown a sincere interest in providing security in the regions they control, others act according to their own rules.

Confronting their presence is therefore vital if the rule of law is to be established in Libya.

But how will this happen?

Hundreds of militias... control more than two million handguns, machine guns and assault rifles... They also possess tanks

Anxious to promote a violent understanding of jihad and believed by some to be responsible for Mr Stevens's death, Ansar al-Sharia is only one example of militia lawlessness.

There are others, driven by a desire for revenge, who have carried out torture against individuals and communities suspected of being loyal to the late Libyan leader, Col Muammar Gaddafi.

And then there are the groups seeking to control the flow of petrol, illegal migrants and drugs along the border areas, a struggle fixated on profits and one that has provoked fighting between rival organisations.

The result is that Libya has become a patchwork of factions whose continued presence - one that appears to be empowering warlords over elected officials - makes it difficult to ensure the establishment and maintenance of a single body of law that can apply equally and to all.

This is why recent news of militias disbanding is promising, at least at first glance.

Ansar al-Sharia and other Islamist-inspired militias in the east have announced that they will cease operations.

In the face of widespread public opposition - their headquarters were raided amid mass protests in Benghazi last weekend - they had little choice.

In Tripoli, the capital, a special wing of the beleaguered army has taken action against militias occupying parts of the city.

Libyan authorities have announced that this will continue over the course of the next few weeks.

The problem is that they are unlikely to get very far.

There are, after all, hundreds of militias commanding hundreds of thousands of fighters who, in turn, control more than two million handguns, machine guns and assault rifles seized from the Gaddafi regime or obtained from foreign sources - Qatar in particular.

They also possess tanks.

Chasing them out of cities and towns will also prove ineffective for the same reasons - the militias that agreed to disband have not surrendered their arms.

Instead, an approach that breaks the source of militia power - the control of weapons - by giving their members the option of handing in their guns in return for rewards that could secure their future might prove much more promising.

Image caption
A special wing of the army has been set up to tackle Tripoli's militias

This also applies to the pro-Gaddafi militias who could be behind the recent killing of Omran Ben Shaaban - one of the rebels credited with capturing Col Gaddafi - among other attacks.

The problems facing Libya today are not unique. Societies emerging from war almost always face the challenge of how to handle fighters and their weapons.

Their experiences could provide Libyan policymakers and the international community - who will need to help the resource-strapped government implement a solution - with lessons.

Sewing machines

The case of three states in particular - Cambodia, Albania and Mozambique - stand out.

Putting money into the hands of fighters is a good idea in theory; in practice, this leads to a rise in prices, guns included

In each of these countries, weapons collection programs were introduced through the mid-1990s and early 2000s in order to deal with the impact of war (as in the cases of Cambodia and Mozambique) and corruption (in Albania, where a pyramid scheme resulted in hundreds of thousands losing their savings. Angry and looking for a bargaining chip that could help them recoup their lost funds, the victims took more than half a million weapons from storage facilities owned by the state).

The main idea behind the programmes centred on provided fighters and communities with incentives to hand in arms and ammunition in their possession.

In Cambodia and Albania, non-governmental organisations, the United Nations and the European Union introduced job training programs and granted development projects built by locals - roads, electricity, water supply systems and upgrades to schools and hospitals - to areas that handed in a predetermined number of weapons.

In Mozambique, in an initiative organised by church groups, those who gave up their arms were given tools - sewing machines, hoes, seeds, bicycles and household goods.

These approaches helped address the weapons problem while giving the fighters and their families the resources they needed to gain sustainable employment. Each programme cost less than $10million (£6.15m) and helped to avoid the spike in inflation that so-called "weapons buy-back" programmes tend to cause. Putting money into the hands of fighters might be a good idea in theory. In practice, this leads to a rise in prices, guns included.

Coupled with this will be a need to recognise that a national military and police force - one that can uphold the rule of law - will need to be based on existing militias rather than the current forces whose reach is limited by a lack of resources, a legacy of the Gaddafi reign - the "brother leader" always feared the subversive potential of the armed forces in particular.

Curbing corruption

The National Transitional Council - the interim authority established during the uprising - attempted to put this in motion by reining in many of the stronger militias and providing their members with a salary that exceeded the average citizen's wage.

Image caption
After protests in Libya over the weekend, militias have agreed to disband

The attempt failed and the militias continued to act independently.

The newly elected assembly can avoid this fate not by crushing the militias - it could not do so even if it tried - but by following a model similar to the one pursued in Cambodia.

To curb corruption and establish better relations between the police and the population, officers were not only provided with good pay, but their family members were given agricultural training and lessons in sewing and motorcycle repair.

This reduced the pressure to act outside of the law because it gave job opportunities to more than one member of the home.

Although it is not certain that militia members would react positively if something similar was introduced, the policy is worth thinking about.

The events of the past few days make clear that there is a desire for change among the population and the country's leadership.

Yet, this is not enough.

The militias will only be brought under control if their members are provided with the kinds of choices that will allow them to live meaningfully.