THERE was never any doubting the brutality of Islamic State (IS), the jihadist group that has swept across large parts of Syria and Iraq and declared an Islamic caliphate. Its war has been accompanied by a stream of gory video recordings of mass-executions and ethnic cleansing. As America has joined the fight against IS, deploying bombers and drones to help Iraqi allies push back the jihadists, the group has started to kill Western hostages it had hitherto held for ransom.

On September 2nd it released a gruesome video of the beheading of Steven Sotloff, an American journalist, supposedly in response to America’s “arrogant foreign policy”. It was the second such atrocity in a fortnight; last month another American journalist, James Foley, was killed in exactly the same way. IS threatens to behead a British captive next.

The group’s startling expansion and lust for blood are only fuelling demands for a more forceful international response. But many of the West’s potential or de facto allies are scarcely more savoury. Some of the most capable anti-IS forces are the Shia militias that once fought American soldiers and waged a vicious sectarian war against Sunnis.

On the same day as the video of Mr Sotloff was uploaded, images circulated of men, allegedly from Asaib Ahl al-Haq, a notorious Shia militia, posing triumphantly with the charred bodies of Sunnis in Iraq. On August 22nd Shia gunmen shot 68 Sunnis dead in a mosque in Diyala province. Human Rights Watch, a New York-based lobby, has accused government-backed Shia militias of kidnapping and killing scores of Sunni civilians this year.

As America embarked on air strikes against IS in Iraq on August 8th, it was at pains to stress that it was not siding with the Shias. Indeed it has been keener to use air strikes to help Kurdish forces in northern Iraq than to aid the Shia-led authorities in Baghdad. And when debating possible strikes against IS’s bastion in Syria, American officials say they are “not on the same page” as Bashar Assad, Syria’s president, who comes from the Alawite sect, often regarded as a Shia offshoot. That said, the recapture on September 1st of Amerli, an Iraqi town home to Shia Turkmen, shows that America will struggle to avoid co-operating with Shia militiamen. The operation was ostensibly led by the Iraqi army, with whom the Americans say they were co-ordinating their air strikes. But it could not have succeeded without several Shia militias. These display stronger fighting spirit than regular Iraqi forces, and have gained experience fighting not only against Americans in Iraq but also for Mr Assad in Syria. The myriad Shia fighting groups are linked either to Iran’s powerful clandestine arm, the al-Quds organisation of Iran’s Revolutionary Guard; or to the Iraqi Shia cleric, Muqtada al-Sadr; or to factions of the Shia-dominated government. They expanded rapidly after America’s invasion of Iraq in 2003 and were believed to run death squads during the sectarian war in 2006-07. Most of these fighters later put down their weapons, but the rise of IS has prompted a surge in new recruits. At least four Shia militias took part in the battle for Amerli: the Badr Corps, set up in the 1980s by Iran to challenge the Iraqi regime of Saddam Hussein; Asaib Ahl al-Haq, which is popular among new recruits because of its audacity and cruelty; Kataib Hizbullah (not directly related to Lebanon’s group of the same name), a well-trained outfit linked to Iran; and Saraya al-Salam, a rebranded version of Mr Sadr’s Mahdi army, which was formally disbanded in 2008. Smaller militias of 100-150 men have popped up since June, when Ali al-Sistani, Iraq’s highest Shia authority, urged men to volunteer (for the army, not militias) to defend Baghdad after IS took Mosul, Iraq’s second biggest city.

If the West wants to counter IS, it may have no choice but to co-operate, explicitly or implicitly, with such Shia fighters. Many Sunni groups that once helped America repel Sunni jihadists have gone over to IS, while the Kurds may have only a limited ability to advance beyond their heartland.

Iraq’s Shias, Kurds, Christians and even many Sunnis initially welcomed the Shia militias because few trust the regular Iraqi army to defend Baghdad. But the very strength of the Shia militias will make it harder to woo disgruntled Sunnis, even with offers of more political power and jobs in the army. Shia militiamen balk at the idea of giving Sunnis more rights, and exert influence through shadowy connections to religious or political figures rather than through parliament. All this bodes ill for Haidar al-Abadi, Iraq’s prime minister-designate, as he seeks to meet a deadline on September 10th for the creation of a new, more inclusive government—a cornerstone of any American plan.

In Syria the conundrum is even trickier, since the West is at odds with both IS and its ostensible enemy, the regime of Mr Assad. Less extreme Sunni rebels pushed IS out of several towns at the start of the year. But, short of weapons, their campaign has run out of steam.

The Syrian army and its various allies are thus IS’s strongest foes. The thinly-spread Syrian army has been bolstered by several Iraqi Shia militias, often seeking to defend Shia shrines such as Saida Zeinab in Damascus. Many of them pulled back to Iraq this summer. The National Defence Forces, a Syrian paramilitary outfit, was created with Iranian help. Another Iranian protégé, Hizbullah, Lebanon’s Shia militia hardened by wars with Israel, has been prominent in battles near Damascus.

Mr Assad’s forces are vile too. On September 2nd Syrian government thugs reportedly slit the throats of 13 Sunni civilians in a village near Hama. Government bombs and rockets continue to wreak daily carnage among civilians. And yet, as war splits Iraq and Syria along sectarian lines, any American action against IS risks unwittingly supporting Iran and the Shias, thereby deepening the very sense of Sunni victimhood on which IS feeds.