Two years after the Libyan revolution, the police and army remain weak and hollow. Neglected by Col. Muammar el-Qaddafi in favor of more loyal units commanded by his sons, they are ill-equipped, understaffed, bloated at the senior ranks and tainted by their association with the old regime. Into their place have stepped the country’s 300 revolutionary militias — the groups that fought in the 2011 revolution that overthrew Colonel Qaddafi or arose in its aftermath.

 On Saturday, throngs of protesters in Benghazi stormed the headquarters of a government-sponsored militia, Libya Shield, whose members opened fire, killing at least 27 people. Weary of Libya Shield’s overbearing presence, the crowds had demanded that the regular army and police take its place. It was a disheartening reminder of the Faustian bargain that Libya’s anemic and fractured government has made with the militias.

Libya Shield is part of a constellation of Islamist-oriented militias that arose in Benghazi during the revolution. Some of these armed groups have fallen under the authority of the government while others, like Ansar al-Sharia, have not. (These groups decry the term “militia,” given its connotation of illegitimacy and lawlessness).

Bereft of the means to project authority and provide security, Libya’s transitional government tried to co-opt the militias in late 2011 and bring them under the control of the Army chief of staff and the Interior Ministry. And so Libya Shield and the Supreme Security Committees were born.

Across the country the Committees and Libya Shield have played the roles of de facto police department and army: they arrest drug traffickers, patrol the western and southern borders, and try to quell tribal fighting in the country’s provinces. Increasingly though, they have become a law unto themselves, pursuing agendas that are regional, tribal, Islamist and sometimes criminal.

When I met last month in Benghazi with one Libya Shield commander, Wissam bin Hamid, he evinced a quiet contempt for the central government and the regular army as Qaddafi-era holdouts. An Islamist engineering graduate and war hero in his mid-30s, he surrounds himself with a coterie of wiry militiamen.

Despite his subordination to the chief of staff, Mr. Bin Hamid was clearly reluctant to surrender his newfound autonomy. He criticized recent efforts by the Libyan special forces to move in on his turf. And last month, militias allied with Mr. Bin Hamid besieged the parliament and a number of ministries demanding the passage of a law that would bar Qaddafi-era officials from further government service. Next, they demanded the resignation of Prime Minister Ali Zeidan.

Now the increasingly isolated Mr. Zeidan has approached the United States about training a general-purpose military force, consisting entirely of fresh “nonmilitia” recruits. On the surface, the proposal is attractive — beef up a “real” army to confront extremists and persuade the militias to disarm and integrate. But it is highly risky and could throw the country deeper into strife.

First, it is unclear if parliament and other parts of the Libyan government back the plan. Moreover, without sufficient oversight, the new force could become another militia among militias, a palace guard for an already-despised politician who will become increasingly loathed, especially by Islamists, for his visible association with America.

Building such a force from scratch takes time. Colonel Qaddafi’s systematic neglect of the army left a military devoid of qualified and trained lieutenants and captains, who form the backbone of any fighting force. Creating a reliable national army would take at least six or seven years. And if it runs into trouble with battle-hardened militias — which is likely — will America be obliged to assist?

Most crucially, the plan fails to address the roots of the crisis: uneven provincial development, unemployment, a lack of transparency in the government, and tensions between Libyan elites who accommodated the Qaddafi regime and those who were persecuted by it. These are problems that cannot be confronted head-on with another armed force.

What is needed instead is a new social contract that reconciles Libya’s factions and produces a government with real legitimacy. Last year’s parliamentary elections were an important first step on that journey. A plan under consideration by parliament to integrate the militias into a national guard-type force, until the regular army is bolstered, is also wise. Although not without flaws, this idea offers the best hope for coaxing the militias back under the umbrella of the state.

Libya would then need a constitution that clarifies lines of command for the military and decentralizes power to municipal governments. For many militias, especially Islamist ones in Benghazi, the constitution is a prerequisite for any disarmament and integration.

Following the United States model, militia leaders told me last month that Libyan army officers should pledge to defend the constitution, not the head of state. That is a noble goal. Rushing to create a new Praetorian Guard with unclear lines of authority and minimal popular support is not the answer.

This article was originally published in the New York Times.