Iraqi forces have recaptured the refinery town of Baiji and broken the siege of the giant oil refinery nearby, say officials in Baghdad – in the most important success for the Iraqi government since Isis seized a third of Iraq in June.

Isis fighters, after their spectacular victories in Iraq and Syria over the summer, are overstretched as they seek to extend or defend the vast territories they have seized. A Kurdish general, Najat Ali, commanding Peshmerga soldiers in the town of Makhmour, 50 miles north of Baiji, said yesterday that “Isis has big administrative problems in supplying food and ammunition to its forces in the front line”.

Makhmour, a Kurdish town of 12,000 people, lies just to the east of the Tigris River and was briefly captured by Isis, which calls itself Islamic State, in its offensive in August that led to the start of US air strikes. It too is back in Kurdish hands.

A shattered 120mm artillery piece, captured by Isis from the Iraqi army but later destroyed by US bombers, lies abandoned near the town’s main grain silo. Kurds were shocked and frightened at the time by the speed with which Isis columns defeated the Peshmerga in blitzkrieg attacks and came close to capturing the Kurdish capital Irbil, which is only 45 minutes’ drive from Mahkmour.

From the top of a mound defended by a machine-gun post on the outskirts of the town, the Peshmerga watch the Isis front line, which is in a treeline and an abandoned village in the middle distance.

They speak respectfully of the deadly accuracy of Isis snipers, but the Peshmergas’ morale has rebounded since they fled before the advance of small Isis units five months ago. Dasko, one of the Peshmerga fighters at the post, said that “American air strikes will prevent Daesh [the Arabic acronym for Isis] from advancing again”.

The return of Kurdish self-confidence may be premature. Isis may be feeling the strain, but is by no means on the run. In the past six weeks it has captured most of Anbar province, covering a great swathe of western Iraq, defeating the Iraqi army in a series of engagements.

It has inflicted savage punishment on the Sunni Arab Albu Nimr tribe which fought against it in central Anbar. The tribe says that 497 of its members, including 20 women and 16 children, were executed by Isis in massacres aimed at deterring other tribes from resisting Isis. The Albu Nimrs’ desperate appeals to Baghdad for help in the shape of weapons, ammunition and air strikes met with no response.

In the wake of these defeats, the new Iraqi Prime Minister, Haider al-Abadi, has this week purged the top command of the Iraqi army, sacking 26 senior officers, retiring another 10 and making 18 new appointments.

Among those removed is General Rashid Flaih, head of the Anbar Operations Command, who presided over a series of debacles that has left 80 per cent of Anbar under Isis control. He had been criticised for failing to get supplies to a besieged Iraqi army base at Saqlawiyah, north of Fallujah, whose 700-strong garrison he described as “whingers”. It was ultimately overrun in a surprise assault on 21 September by Isis fighters in disguise, wearing Iraqi army uniforms and driving captured American Humvees. The garrison thought this was an Iraqi army relief force until it was too late.

Since then the Iraqi army’s position in Anbar has continued to deteriorate. An aid worker says that “some 100,000 people are besieged and entirely cut off by Isis in the Sunni city of Haditha on the Euphrates. The US air force dropped some 7,000 meals but they have received no other supplies.” General Martin Dempsey, Chairman of the US Joint Chiefs of Staff, told Congress this week that 80,000 efficient troops would be needed to defeat Isis.

If Isis is overstretched, so too are its opponents, particularly the Kurds who have to defend a 650-mile-long frontier with the new “caliphate” declared by its leader Abu Bakr al-Baghdadi on 29 June. A leader of the Patriotic Union of Kurdistan, one of the two main Kurdish parties, Saadi Pira, says that “on 10 June we woke up and found we had a new neighbour in the shape of Isis, whose territory stretches from Iran to Syria”.

He believes that Isis is weaker than it was at the height of its success, when it had won an unbroken series of military victories and was generally supported by Iraq’s Sunni community, which had been persecuted by the former Prime Minister Nouri al-Maliki during his eight years in power.

Mr Pira says: “The Sunni community was willing to co-operate with the devil to punish Maliki.” Many Sunni may have come to regret their previous support for Isis, but they are equally terrified of the return of the Iraqi army, the Shia militias or the Kurds.

The Isis force that captured Makhmour on 8 August was only about 150 strong, according to Porat, an official of the Kurdistan Workers’ Party (PKK) at a Turkish Kurd refugee camp at Makhmour, whose inhabitants fled from Turkey in 1998.

A peculiarity of this part of Iraq is that the political and military situation in every district is determined by the varying local political, ethnic and sectarian balance. In Makhmour, the 12,000 Kurds in the camp are an important factor in the local balance of power. The PKK evacuated them in the face of the Isis offensive, but summoned some 200 PKK guerrillas from their base in the Kandil Mountains in north-east Kurdistan who had plenty of recent military experience in fighting the Turkish army. Fighting together with the Iraqi Kurdish Peshmerga, the PKK drove Isis out of the town.

For long ignored or demonised by the rest of the world, the PKK militants unexpectedly find themselves lauded for their heroic defence of Kobani, Mount Sinjar and towns like Makhmour. At the entrance to their camp workers were labouring yesterday to build a large plinth for a statue or picture of their leader, Abdullah Ocalan, imprisoned by Turkey since 1999.

ORDER IT NOW

The Iraqi Kurdish authorities are somewhat irritated by the praise being lavished on the PKK’s military prowess but for the moment fear and hatred of Isis is a strong bond for all the Kurds. One PKK official in Makhmour said, “I should really thank Daesh because they have united the Kurds and publicised our cause before the world.”

Najat Ali, the Kurdistan Democratic Party commander in Makhmour, says that Isis is weakened by being no longer able to use its captured heavy artillery and Humvees because of US air strikes. Knowledge that US air power is protecting them had done a lot to raise Kurdish morale. He says: “Isis’s psychological tactics, spreading terror through their atrocities, no longer works as [they] once did.”

The recapture of Baiji refinery after months of fighting would boost the morale of the Iraqi government, though its most effective units are often Iranian-backed Shia militiamen.

Each side, if it concentrates its forces, can punch through the thinly held battle lines anywhere in Iraq and win a local success.

But such is the degree of sectarian and ethnic hatred that these little victories lead to mass flights of people who support the losing side.