THE COUP against Egypt’s first elected government has raised the pressure on two other North African states that revolted against authoritarian Arab regimes in 2011 and sought to establish democracies in their place. In Tunisia, an elected Islamist administration, struggling to reach consensus with secular opponents, was shaken last week by the assassination of a secular opposition leader, apparently by jihadists. That could animate a movement seeking to emulate Egypt’s mass demonstrations and provoke another military intervention. However, if a much-delayed constitutional process moves forward, Tunisians will have the chance within a few months to change their government in parliamentary and presidential elections.

In neighboring Libya, the situation is more troubled. A provisional parliament elected in the country’s first democratic vote has been paralyzed by infighting and intimidated by outside forces, including the unaccountable militias that are Libya’s biggest problem. This month, however, the assembly managed to move the country a step closer to stability by approving a law for the election of a constituent assembly that will prepare a new constitution.

Under dictator Moammar Gaddafi, Libya lacked not only a recognizable constitution but also institutions of all kinds, including courts, professional armed forces and police; all were subsumed by the ruler’s bizarre totalitarianism. The country is rich in oil and gas and sparsely populated, which in theory should make its modernization far easier than Egypt’s. But the question is whether the slow and painful process of creating a viable state will be overwhelmed by the lawlessness that is the Gaddafi regime’s legacy — including dozens of armed groups that sprang up to overthrow the regime in 2011.

One of those groups, Ansar al-Sharia, is believed to have been involved in the attack on the U.S. mission in Benghazi last Sept. 11. Another opened fire on Benghazi citizens who were demonstrating against it in June, killing more than 30. On Saturday, a prison break in Benghazi freed more than 1,000 detainees, including many militants. Militants also besieged the elected assembly, which was cowed into passing a counterproductive law banning from office all former officials of the Gaddafi regime.

Prime Minister Ali Zeidan, a liberal democrat under growing pressure from Islamists as well as the militias, has been pleading with Western governments for help in building armed forces and police that can absorb some of the militias and take on extremists like Ansar al-Sharia. Sadly, the response from the Obama administration and its allies has been minimal: Italy, Libya’s former colonial ruler, has been tasked with providing help. Its fragile and austerity-minded government says it will train, with help from Britain, a few thousand members of the security forces in and outside of Libya.

The United States and other governments that participated in NATO’s 2011 intervention in Libya should be doing far more, including implementing a larger military assistance program. In Libya, as in much of the Arab world, a real chance to create modern democratic institutions is balanced by the threat of chaos; the Obama administration is missing an opportunity to promote one over the other.