Sabratha, Libya

Ahmed “al-Amu” Dabbashi, the 28-year-old leader of a militia in this seaside town near the Tunisian border, proudly unfurls a black Islamic State flag, seized during late-February raids on safe houses of ISIS, as the group is also known. He shows me a captured arsenal, too: truck-borne explosives, detonators, crates of ammo, crew-served machine guns, and identification cards of foreign fighters.

Days earlier, American warplanes had bombed an Islamic State training site at a nearby house. Then, al-Amu tells me, “we decided to cleanse our town.” In the raids that followed, fighters for the so-called caliphate struck back, assaulting a police station and cutting the throats of several officers. Scores of youths perished in gunbattles.

Elsewhere across Libya, disparate factions are trying to hold the line against ISIS, often tenuously. The terrorist group is most entrenched in the central city of Sirte. Refugees fleeting Sirte tell me that ISIS extorts businesses and stops traffic to conduct executions.

In late March, a new presidential council—formed under the auspices of a U.N.-brokered unity agreement—arrived with great fanfare in the capital of Tripoli. Washington and its allies had hoped this would provide a foundation for a military campaign against ISIS. But after an initial burst of public enthusiasm, the council is struggling to exert its authority.

The fight against Islamic State faces daunting challenges. First, there still is no unified military structure through which the U.S. and Western allies can channel assistance. A powerful eastern faction allied with Gen. Khalifa Haftar remains hostile to the unity agreement and has tried to sell oil independently from Tripoli. Other militias, even if nominally supporting the new government, remain beholden to towns, tribes and power brokers.

Thus, Western special forces must work with militia surrogates in any operations against Islamic State. But this is risky: Assisting these armed groups could rekindle old rivalries and further reduce the incentives for national reconciliation.

Militias have figured out that signing up for the campaign against Islamic State is the best way to get legitimacy and attention. Whether or not they intend to use outside support solely against ISIS is another story. Many still regard their local rivals as the pressing concern. In some cases, the West may find them unsavory partners: traffickers, hard-line Salafists, tribal supremacists, military officers with authoritarian and anti-Islamist leanings.

This is evident in Sabratha, where al-Amu’s extended family has had longtime links with smugglers and jihadists. In the capital of Tripoli, a Salafist militia leader lets me tour his prison’s rehabilitation center, where Islamic State suspects are thrown in with drug addicts for undefined stretches with no due process. In a trip to Benghazi last fall, I saw how neighborhood militias carried out what amounts to personal and tribal vendettas, all under the cover of combating Islamic State.

Western powers must navigate this landscape carefully to avoid throwing the country into further chaos. Support should only be lent to those armed groups that have subordinated their forces to the unity government, agreed to subject their members to vetting for human-rights violations, and committed to eventual demobilization and a civilian-controlled military. In areas liberated from ISIS control, Washington and its partners should plan for the quick return of displaced persons and encourage social reconciliation.

Nowhere are these imperatives more vital than in the area surrounding Sirte, where rival militias from east and west have converged in recent days. They have set up competing “operations rooms,” supposedly to oversee the movements of their respective forces in attacking Islamic State. But these bodies so far do not talk to one another in a meaningful way and are less about battlefield coordination than factional theatrics.

For its part, the new unity government is dependent on militias from the coastal city of Misrata, roughly 170 miles west of Sirte. But Misrata’s forces are militarily weak. Last week ISIS conducted suicide attacks, killing more than a dozen Misratan forces and capturing nearby hamlets.

Moreover, tribes in the Sirte basin tacitly welcomed rule by ISIS as a counterweight to abuse by forces from Misrata. “Better the hell of ISIS than the paradise of Misrata,” one Sirte refugee told me. With tensions still bubbling, any move by Misrata-led militias could backfire unless it is coordinated carefully with local fighters from Sirte.

Similarly, a unilateral assault on Sirte by Gen. Khalifa Haftar could trigger pushback from western factions, which continue to view him as a threat. Last week Gen. Haftar’s self-styled Libyan National Army clashed with militiamen allied with Misrata. The net result of this infighting is greater space for ISIS. Given these divisions, the West should only aid an effort to liberate Sirte once a centralized command structure is in place that can temper the risks of a destabilizing scramble for political leverage and oil resources.

Most Libyans I meet are sick of the divisions that have afflicted their country. They condemn the politicization of the anti-ISIS struggle by quarrelsome elites, and they welcome Western assistance. But Washington and its partners must proceed with caution, to ensure that the fight against Islamic State does not further fracture the country.

This article was originally published at the Wall Street Journal