IF SENTIMENT in the towns in or bordering the so-called “caliphate” of Islamic State (IS) is anything to go by, the jihadists are winning the war. “IS is here to stay,” a doctor in Falluja says of the group’s grip on Anbar, Iraq’s largest province. It is a sharp reversal from just a few months ago, when the campaign against IS seemed to be going quite well. Then, Syrian Kurdish fighters had defeated IS in Kobane. In Iraq the jihadists had been pushed out of 25% of the territory they had grabbed in their blitzkrieg advance a year ago and been expelled from Tikrit, Saddam Hussein’s hometown. There was even talk of an offensive later in the year to retake Mosul, Iraq’s second-biggest city. But after the retreat of Syrian regime forces from Palmyra, the black flag of IS now flies over the ancient city; while Ramadi, the capital of Anbar province, fell on May 17th. The idea that IS was in retreat has thus taken a severe jolt.

Barack Obama describes the loss of Ramadi as a mere “tactical setback”. But a blame game has since broken out. America’s defence secretary, Ash Carter, complained that the collapse of the Iraqi security forces against numerically inferior opposition was due to a lack of “will to fight”. Domestic critics of Mr Obama, such as John McCain, chairman of the Senate Armed Services Committee, talked of a half-hearted and failing military effort. They all have a point.

The capture of Ramadi is not a game-changer. It had been under attack for many months and it is quite possible that an attempt already under way by Iraqi forces and their Iranian allies to retake the city will succeed. In April media screamed that IS was poised to enter Damascus after it popped up in Yarmouk, a Palestinian area on the outskirts of the capital. With much less fanfare, the group disappeared—one Syrian says the capital feels safer than it has done for months. In recent days Iraqi forces have recaptured Husayba, a small town in Anbar, and halted IS’s approach towards Habbaniya, a military base.

In any case the group’s recent successes owe more to the weakness of the forces opposing it than to its own strength. The regime of Bashar Assad in Syria is looking wobblier than at any time since 2012. Its army fled Palmyra. Although Iraq’s Shia militias put up a good fight in places, its Shia-dominated and often badly led army is reluctant to fight and die for Sunni territory. Unless it improves the jihadists may advance further. The government remains reluctant to arm the Sunni tribesmen who might defend their homes.

The recent gains by IS also do little to address its weaknesses. It needs to generate huge funds to maintain its pretension to be a caliphate, yet its income streams, such as those from illicit oil sales, ransoms and looted antiquities, are all vulnerable to concerted pressure and windfalls from conquest are dwindling.

Its top-down structure leaves it vulnerable to “kill or capture” raids by American special forces (like one in Syria on May 15th that resulted in the death of Abu Sayyaf, the outfit’s financial brain). A more concerted air campaign could also set it back. Western forces are managing a meagre 15 strikes a day (compared with the 50 a day NATO carried out against Qaddafi’s less formidable forces in Libya). Mr McCain says that 75% of sorties fail to fire a weapon or drop a bomb, because targets are not identified. That might change if America provided forward air controllers. Were American military advisers and trainers embedded with Iraqi forces when they go into action it would stiffen their resolve.

The Iranians also need to reflect on their strategy. Propping up the increasingly fragile regime of Bashar Assad is a failing policy that serves only to strengthen IS. As for the Iraqi government of Haider al-Abadi, it ought to honour its promises of inclusivity. Sunni tribal fighters in Ramadi, denied weapons and military support by a mistrustful Baghdad, are hopelessly out-gunned. America could do much more to help. But, above all, it is Iraq’s poisonous sectarianism and the Syrian regime’s brutality that feeds IS.