Libyan citizens watching the damage caused by a missile that struck a building in Tripoli, Libya 04 August 2014. Rival militias have been fighting for two weeks for control of the main airport in Tripoli. At least 200 people have been killed in the violence. (Str/EPA)

Chibli Mallat is chair of the group Right to Nonviolence. Duncan Pickard is a nonresident fellow at the Rafik Hariri Center for the Middle East and was Libya country director for Democracy Reporting International.

President Obama said this month that perhaps his biggest foreign policy regret was providing insufficient support to Libya’s fledgling political institutions after the fall of Moammar Gaddafi. Obama said that he underestimated the need for the United States and its European allies to come in “full force” after the military intervention, given Libya’s lack of “civic traditions” after 42 years of dictatorship.

The failure of Libya’s political institutions has had dire consequences. The violent character of the Libyan revolution, in contrast to the other 2011 Arab Spring uprisings — including, at the time, in Syria — did not help. The militias that rose against Gaddafi sought to set terms and win power by force. The interim government was too weak to consolidate the militias, which are now waging a makeshift war in Tripoli and Benghazi along ideological lines. The swaths of Libya that remain outside the government’s control have become ideal recruiting grounds for international jihadist organizations, and unmanaged stores of weapons pass through porous borders to Tunisia, Algeria and Mali.

Libya’s situation is dire, but there still are steps that Obama and the international community should take. Currently, Libya’s political transition is proceeding along four disjointed tracks: the workings of a new parliament, efforts to select a new government, a constitution-making process and a U.N.-backed national dialogue that is intended to broker broad agreement on the founding principles of the Libyan state. These tracks are poorly coordinated and all, except for the national dialogue, have been the target of violence.

In a conversation that one of us (Mallat) had in July with Tarek Mitri, the U.N. special envoy to Libya, it was clear that the choice was stark: The U.N. support mission either needs to be given the military and institution-building means to assist the large nonviolent majority of the population or it should leave. Indeed, it evacuated its foreign staff last month because of increased security risks in Tripoli. Despite the evacuation, on Aug. 6, the newly elected parliament called for the United Nations to broker and supervise a cease-fire among the militias, and it has since called for a cease-fire reached through “political means,” stating that “naturally . . . these solutions cannot be imposed by force.” The mission has said it will return once the security situation improves. And it should — but only with the resources needed to revive the unique spirit of unity that prevailed shortly after Gaddafi’s death.

A U.N. role in brokering peace could open an avenue for the international community to take greater control of the political transition. As in Yemen, which has been governed by a multilateral agreement since 2011 , weak Libyan institutions need to be propped up from the outside. There is even a Libyan precedent: The current constitutional committee is modeled after Libya’s U.N.-supervised 1951 constitution-making process.

The appointment of a new government also requires committed diplomacy led by the international community. Libya has had seven prime ministers since Gaddafi fell. The current one, Abdullah al-Thinni, initially refused to form a government after an opposing militia threatened the lives of his wife and children. His weakness led the militia guarding the all-important oil terminals in the east to rescind its loyalty agreement with him. The next prime minister must be able to act without militias holding veto power through the barrel of a gun.

With substantial support from the European Union, and logistics that only the United States can provide, the United Nations should revisit a request made last year by then-prime minister Ali Zeidan to train and fund an elite force to protect government institutions. Libya’s military institutions are as weak as its political ones. The militias are small, do not operate with strict command and control and rely on surplus materiel cobbled together from Gaddafi’s army. The military order in Libya has not yet been established. Just last week, 2,000 people took to the streets of Benghazi to call for the militias to leave the city. White House officials have said that it was moved to action in Iraq in part to avoid “another Benghazi.” They should apply some of the same logic to Benghazi itself.

A new assistance program in Libya would require the active build-up of the military, with NATO supervision. Libya must also reactivate its stalled processes of institution-building, working toward an inclusive constitution and a government that can persuade militia leaders to lay down their arms — or else pay a financial, political and military price. As in the other Middle Eastern countries free of dictators, Libyans seek a government that delivers security and holds a monopoly on violence. If he moves now to get them the support they need, perhaps Obama won’t be doomed to live with his regrets.