In a surprising turn of events, a document circulating on Libyan social media purports to show the often fractious militias from the city of Misrata, which have featured prominently in the country's recent divisions, pledging their support to a unity government. The two major factions in the country's ongoing armed conflict have yet to reach agreement on a unity government even after an U.N.-brokered year-long dialogue.

A man holds a sign during a protest against candidates for a national unity government proposed by U.N. envoy for Libya Bernardino Leon, in Benghazi, Libya October 23.

© Esam Omran Al-Fetori/Reuters

With almost 60 stamps of support from different militias, the document epitomizes all that went wrong in dealing with the myriad militias in Libya's post-conflict phase. Four years after the end of the uprising, Libya is beleaguered with hundreds of unaccountable armed actors nationwide, some of them holding thousands of detainees unlawfully and torturing people, instead of a unified, accountable, and rights-respecting security force.

This document clearly shows the immense challenges facing international, regional, and local brokers in achieving broad support for a unity government and a reasonable road map for creating a military and police force along national—not tribal or regional—lines that will answer to the unity government. But to do that, the chief U.N. peace broker, Bernardino Leon, and supporting countries—including the U.S., France, and the U.K. as well as the E.U.—will need to ensure that the issue of holding to account those who have committed serious crimes isn't completely sidetracked for a political deal.

The U.N. effort has focused on forging a deal between the internationally recognized government and its House of Representatives based in the eastern cities of al-Bayda and Tobruk, and a self-declared government backed by the rump General National Congress based in Tripoli, the capital. The process has been complicated by ongoing armed hostilities, shifting alliances on both sides, enduring regional divisions, and diverging interests of neighboring countries and regional powers.

Other complicating factors include local conflicts and the dissatisfaction of Libya's vast southern region and ethnic minorities over their perception that they are being marginalized in the negotiations on Libya's future, as well as the growing presence of extremist groups.

Neither of Libya's rival governments has yet endorsed the agreement, and all parties seem to be squabbling over positions and their share of power. But the legal expiration of the authority of the House of Representatives on October 21 and the risk of a complete constitutional vacuum makes it all the more urgent to complete an agreement.

The National Transitional Council, the body created in 2011, and responsible for the transition to a post-Gadhafi government failed to lay down clear rules for disarming the "revolutionary" armed groups or effectively integrating them into the state security forces. Instead, it created various hybrid forces to "support" the police (such as the Supreme Security Committee), and the army (such as the Libya Shield Forces).

Successive interim governments were unsuccessful in ending support for these groups, which only grew in power and number, reaching almost 200,000 people on the government payroll by 2014, a staggering figure in a country of 6.5 million. While some of these groups were dissolved, former members mostly joined other hybrid forces, some of which are nominally under the control of government authorities. Others remained wedded to their original "revolutionary' orientation," or formed new militias currently embroiled in the ongoing conflict.

Libya's failure to develop a plan to deal with militias was compounded by the international community's commitment to a "light footprint" approach in the aftermath of the 2011 uprising. There was no shortage of offers for international support and training for the post-Gadhafi government's nascent security institutions, but none of the countries that helped defeat Gadhafi were prepared to address the abuses and surging impunity of the militias and National Transitional Council forces. It is striking that this has essentially never been on the agenda of the U.N.-led negotiations.

The United Nations, particularly the Security Council-mandated Sanctions Committee, and the Human Rights Council, also took little action at first even to document militia abuses. This foot-dragging over addressing impunity continued even as torture, forced displacement, mass arbitrary detentions, and politically motivated assassinations by militias mushroomed. This violence in turn fueled local conflicts that have further destabilized the country.

Extremist armed groups, including Ansar al-Sharia, other Al-Qaeda affiliates, and the Islamic State (also known as ISIS), used this vacuum to expand their foothold in some areas.

The local justice system has also failed to prosecute militia members for serious crimes. In fact, the domestic criminal justice system has collapsed in most of the country due to threats and assassinations against judges and prosecutors, as well as the challenges posed to a national judicial system under the two rival governments. And although the Security Council referred the situation in Libya to the International Criminal Court in 2011, the ICC prosecutor has not opened any investigations beyond the role of former Gadhafi officials in the 2011 uprising, citing security concerns and a lack of resources.

Unity government discussions need to include a viable enforcing mechanism to disband the militias and absorb some of their fighters into a formal, accountable security and justice structure with clarity over the basic rules, including who has the legal authority to arrest and detain. Addressing the problem of unaccountable armed groups will be the cornerstone of any future deal.

The international negotiators should not leave this issue on the margins, thinking it can be dealt with later. If they do, the abusive unaccountable militias will only continue to drive the cycle of mass crimes and impunity.