The American commando operation that snatched a suspected leader of al-Qaida from his neighborhood in Tripoli, while successful, does not offer a permanent strategy to the threat from extremists in Libya. That point was reinforced Thursday when the country’s prime minister, Ali Zeidan, was briefly kidnapped by militia members in apparent retaliation for his consenting to the raid.

In the long term, Libya’s stability will depend on the country developing its own security forces and strengthening its fragile transitional government. But that will require more assistance from the United States and Europe, which have so far lacked a coordinated vision and the political will to support these two goals sufficiently.

The suspected al-Qaida commander, Nazih Abdul-Hamed al-Ruqai, also known by his alias Abu Anas al-Libi, is under indictment for the 1998 bombings of the U.S. embassies in Kenya and Tanzania and for conspiring with Osama bin Laden to attack U.S. forces in Saudi Arabia, Yemen and Somalia.

There was little possibility that the transition government could have apprehended Ruqai. Since the 2011 revolution that ousted Moammar Gadhafi, the government has barely functioned, the security forces have been in disarray and security has worsened. The country is awash in arms, and the situation is so chaotic that militants, some affiliated with al-Qaida, have begun to use Libya as a base and to smuggle weapons beyond its borders, including into Mali.

The government’s biggest challenge is to gain control of the freewheeling armed militias, which were part of the revolution and vastly exceed the army and police in size and arsenals. But so far, all of its initiatives, including offering the militias incentives to integrate into the army and police forces, have failed. The unrest brought oil production to a standstill earlier in the year, though part of it has been brought back on line.

In response to a request from the Libyan government in the spring, the United States, Britain and Italy have been planning a multiyear program to train and equip a core of about 12,000 Libyan soldiers at a base in Europe, with the cost borne by Libya. The Americans also plan a smaller program to train border guards.

These programs should be started as soon as possible, though neither is expected to improve security immediately. Broader reforms in the Libyan army, including establishing a coherent chain of command, are also crucial. But none of this will amount to much without replacing the interim government with a more permanent and democratic structure that can begin to unify the country’s tribal, regional and political groups and deliver services.

That is unlikely to happen without more sustained help — including increased diplomatic engagement and advice on strengthening the rule of law and writing a new constitution — from the United States and Europe.