Less than a year ago, victorious militiamen swarmed the streets of Libya's major cities basking in their role as national liberators. Today, many of those same men present a challenge to the country's incoming rulers, who face the prospect of long-term instability if they fail to rein in armed irregulars.

The question of how to safely unwind an insurgency like the one in Libya is nothing new — it's a thorny problem that goes back centuries. In modern times, the process known as "disarmament, demobilization and reintegration," or DDR, has had as many failures as successes in places such as Afghanistan, Sri Lanka, Lebanon, Peru and Colombia.

"It's a very, very difficult road," says Aram Nerguizian, a visiting fellow at the Center for Strategic and International Studies.

He says for militia members, there are typically strong group ties that are reinforced by the shared experience of combat, as well as ideology, fear of reprisals from the government or rival groups, and poor prospects for civilian employment that all militate against disbanding. And in Libya and elsewhere, time is of the essence.

"It's very clear that the Libyans have only a short window in terms of trying to make this happen," Nerguizian says.

"The longer you don't take necessary action to conduct meaningful arms control and reintegration and demobilization, the more difficult it becomes in the future, because you establish an environment where the militias grow more entrenched, and then you cannot act," he says, pointing to Lebanon, where 15 years of insurgency ended suddenly, but militias have never been extinguished.

Earlier this week, the head of Libya's newly elected National Congress, Mohammed el-Megarif, issued a 48-hour deadline for militias to disband and be absorbed into the security forces, a common demobilization and reintegration strategy. Mass anti-militia protests this week that came in the wake of the killing of U.S. Ambassador Chris Stevens and three others earlier this month may have strengthened the incoming leadership's hand, but it's not clear how many of the militias have taken up the government offer.

"It sounds like some of these guys are pretty radical and are not going to be all that interested in being co-opted into some sort of central government," says Paul Staniland, a professor at the University of Chicago who studies insurgent and paramilitary groups.

Militias Disband, But Guns Stay

If the militias can be persuaded to disband, getting them to turn in their weapons is yet another challenge. In some places, particularly in South Asia and South America, buy-back programs that pay insurgents to turn in their guns have been tried, but without great success.

"The combatants turn in the junk and keep the best weapons for another day," says Douglas Porch, a historian at the Naval Postgraduate School in Monterey, Calif.

In Afghanistan, for example, the Taliban have used their military muscle to tap into local drug proceeds and extort bribes from truckers in exchange for allowing them to access the roads they need to get their goods to market.

"Many insurgent groups have sidelines in crime, which become their main preoccupation on demobilization," Porch says.

That's why the integration step is so important, says Matthew Levinger, a professor at George Washington University's Elliott School of International Affairs.

"If you're going to take these individuals off the streets, you're going to have to find some kind of career trajectory for them to not be a potential source of instability against any new regime," Levinger says.

However, bringing Libyan militias into the police or military presents its own set of problems, says Nerguizian of the Center for Strategic and International Studies.

"If there are questions of loyalty and questions of being able to follow the chain of command, it's going to make it that much more difficult when you encounter contingencies and you need to deploy forces," he says. "You'll be faced with the kinds of questions that many Lebanese commanders face: 'Is this an environment where I can act decisively, or will clan and tribal loyalties override my orders?' "

Establishing institutional loyalties could take years, and as long as the old militia members are in power, the question of loyalty will remain, Levinger says.

Copyright 2016 NPR. To see more, visit http://www.npr.org/.