TURKEY’S allies in the West have felt increasingly queasy about its wayward president, Recep Tayyip Erdogan. At home he has become authoritarian and wants to change the constitution to give himself more power. Abroad he has been indulgent towards militants passing through his country to fight in Syria. In the year since the jihadists of Islamic State (IS) declared their caliphate in parts of Iraq and Syria, and America gathered a coalition to “degrade and ultimately destroy” them, Mr Erdogan has refused to let NATO allies use Turkish bases.

Perhaps he feared that the jihadists would target Turkey. Or perhaps he thought they were useful pawns in the violent geopolitics of the Middle East. Such illusions should have been blown away on July 20th, when a suicide-bomber killed 32 people in Suruc, a Turkish town on the border with Syria. Within days Turkey said it would allow America to use its base at Incirlik, and its own jets bombed IS. There is now talk of creating a buffer zone in Syria to cut off IS’s last supply lines.

Many hope Mr Erdogan has at last had a moment of clarity about the IS menace. So far, though, he has only added to the murk of the region’s wars. His air force has mostly bombed the Kurds who, in various guises, have proved to be the most resolute fighters against IS. The Kurdistan Workers’ Party (PKK), which has been fighting an on-off insurgency against Turkey for decades, invited retribution by breaking a two-year ceasefire and killing several policemen and soldiers, in reprisal for Turkey’s supposed collusion in the Suruc bombing, which hit a Kurdish cultural centre. But Mr Erdogan is being reckless, too. By deliberately stirring nationalist, anti-Kurdish sentiment, he is endangering the chance of a lasting settlement of the Kurdish question and weakening the fight against IS.

Why the caliphate endures

Under attack from America and an impressive list of allies, IS should by now be in full retreat. There are cracks in the caliphate, to be sure, but it has endured and has at times even taken new territory. Its resilience creates a myth of God-given invincibility that radicalises admirers around the world, draws recruits and spawns copycat groups.

The caliphate survives because its defeat is nobody’s priority. America’s aim is to limit its military commitment in the Middle East. For Saudi Arabia and the Gulf monarchies, the big threat is Iran. Iran’s main mission is to prop up the Syrian dictator, Bashar Assad. Mr Assad’s first concern is holding other rebels at bay. The rebels’ obsession is to get rid of Mr Assad.

The hardest fighting against IS in the past year has been waged, in Iraq, by Shia and Kurdish Peshmerga militias; and, in Syria, by the Kurdish forces of the People’s Protection Units (YPG), an offshoot of the PKK. The Syrian Kurds’ valour in defending the town of Kobane, in full view of television cameras just across the border in Turkey, earned much admiration and the direct support of America’s air force. Though Turkey sheltered Kobane’s fleeing civilians, it watched with indifference as Kurdish fighters desperately fought off IS; it only grudgingly allowed Iraqi Kurds to reinforce them.