America's plans to fight Islamic State are in ruins as the militant group's fighters come close to capturing Kobani and have inflicted a heavy defeat on the Iraqi army west of Baghdad.

The US-led air attacks launched against Islamic State (also known as Isis) on 8 August in Iraq and 23 September in Syria have not worked. President Obama's plan to "degrade and destroy" Islamic State has not even begun to achieve success. In both Syria and Iraq, Isis is expanding its control rather than contracting.

Isis reinforcements have been rushing towards Kobani in the past few days to ensure that they win a decisive victory over the Syrian Kurdish town's remaining defenders. The group is willing to take heavy casualties in street fighting and from air attacks in order to add to the string of victories it has won in the four months since its forces captured Mosul, the second-largest city in Iraq, on 10 June. Part of the strength of the fundamentalist movement is a sense that there is something inevitable and divinely inspired about its victories, whether it is against superior numbers in Mosul or US airpower at Kobani.

In the face of a likely Isis victory at Kobani, senior US officials have been trying to explain away the failure to save the Syrian Kurds in the town, probably Isis's toughest opponents in Syria. "Our focus in Syria is in degrading the capacity of [Isis] at its core to project power, to command itself, to sustain itself, to resource itself," said US Deputy National Security Adviser Tony Blinken, in a typical piece of waffle designed to mask defeat. "The tragic reality is that in the course of doing that there are going to be places like Kobani where we may or may not be able to fight effectively."

Unfortunately for the US, Kobani isn't the only place air strikes are failing to stop Isis. In an offensive in Iraq launched on 2 October but little reported in the outside world, Isis has captured almost all the cities and towns it did not already hold in Anbar province, a vast area in western Iraq that makes up a quarter of the country. It has captured Hit, Kubaisa and Ramadi, the provincial capital, which it had long fought for. Other cities, towns and bases on or close to the Euphrates River west of Baghdad fell in a few days, often after little resistance by the Iraqi Army which showed itself to be as dysfunctional as in the past, even when backed by US air strikes.

Today, only the city of Haditha and two bases, Al-Assad military base near Hit, and Camp Mazrah outside Fallujah, are still in Iraqi government hands. Joel Wing, in his study –"Iraq's Security Forces Collapse as The Islamic State Takes Control of Most of Anbar Province" – concludes: "This was a huge victory as it gives the insurgents virtual control over Anbar and poses a serious threat to western Baghdad".

The battle for Anbar, which was at the heart of the Sunni rebellion against the US occupation after 2003, is almost over and has ended with a decisive victory for Isis. It took large parts of Anbar in January and government counter-attacks failed dismally with some 5,000 casualties in the first six months of the year. About half the province's 1.5 million population has fled and become refugees. The next Isis target may be the Sunni enclaves in western Baghdad, starting with Abu Ghraib on the outskirts but leading right to the centre of the capital.

The Iraqi government and its foreign allies are drawing comfort, there having been some advances against Isis in the centre and north of the country. But north and north-east of Baghdad the successes have not been won by the Iraqi army but by highly sectarian Shia militias which do not distinguish between Isis and the rest of the Sunni population. They speak openly of getting rid of Sunni in mixed provinces such as Diyala where they have advanced. The result is that Sunni in Iraq have no alternative but to stick with Isis or flee, if they want to survive. The same is true north-west of Mosul on the border with Syria, where Iraqi Kurdish forces, aided by US air attacks, have retaken the important border crossing of Rabia, but only one Sunni Arab remained in the town. Ethnic and sectarian cleansing has become the norm in the war in both Iraq and Syria. The US's failure to save Kobani, if it falls, will be a political as well as military disaster. Indeed, the circumstances surrounding the loss of the beleaguered town are even more significant than the inability so far of air strikes to stop Isis taking 40 per cent of it. At the start of the bombing in Syria, President Obama boasted of putting together a coalition of Sunni powers such as Turkey, Saudi Arabia, Qatar, Jordan, United Arab Emirates and Bahrain to oppose Isis, but these all have different agendas to the US in which destroying IS is not the first priority. The Sunni Arab monarchies may not like Isis, which threatens the political status quo, but, as one Iraqi observer put it, "they like the fact that Isis creates more problems for the Shia than it does for them".

Of the countries supposedly uniting against Isis, by the far most important is Turkey because it shares a 510-mile border with Syria across which rebels of all sorts, including Isis and Jabhat al-Nusra, have previously passed with ease. This year the Turks have tightened border security, but since its successes in the summer Isis no longer needs sanctuary, supplies and volunteers from outside to the degree it once did.

In the course of the past week it has become clear that Turkey considers the Syrian Kurd political and military organisations, the PYD and YPG, as posing a greater threat to it than the Islamic fundamentalists. Moreover, the PYD is the Syrian branch of the Kurdistan Workers' Party (PKK), which has been fighting for Kurdish self-rule in Turkey since 1984.

Ever since Syrian government forces withdrew from the Syrian Kurdish enclaves or cantons on the border with Turkey in July 2012, Ankara has feared the impact of self-governing Syrian Kurds on its own 15 million-strong Kurdish population.

President Recep Tayyip Erdogan would prefer Isis to control Kobani, not the PYD. When five PYD members, who had been fighting Isis at Kobani, were picked up by the Turkish army as they crossed the border last week they were denounced as "separatist terrorists".

Turkey is demanding a high price from the US for its co-operation in attacking Isis, such as a Turkish-controlled buffer zone inside Syria where Syrian refugees are to live and anti-Assad rebels are to be trained. Mr Erdogan would like a no-fly zone which will also be directed against the government in Damascus since Isis has no air force. If implemented the plan would mean Turkey, backed by the US, would enter the Syrian civil war on the side of the rebels, though the anti-Assad forces are dominated by Isis and Jabhat al-Nusra, the al-Qaeda affiliate.

It is worth keeping in mind that Turkey's actions in Syria since 2011 have been a self-defeating blend of hubris and miscalculation. At the start of the uprising, it could have held the balance between the government and its opponents. Instead, it supported the militarisation of the crisis, backed the jihadis and assumed Assad would soon be defeated. This did not happen and what had been a popular uprising became dominated by sectarian warlords who flourished in conditions created by Turkey. Mr Erdogan is assuming he can disregard the rage of the Turkish Kurds at what they see as his complicity with Isis against the Syrian Kurds. This fury is already deep, with 33 dead, and is likely to get a great deal worse if Kobani falls.