The other day I was speaking to a Kurdish journalist who was held in Isis captivity for ten months. He and a colleague had had the bad luck to run into an Isis checkpoint in Syria. ‘How do you perform the midday prayer?’ they were asked after their car was waved to a halt. Unable to answer — they were not believers — they were immediately beaten around the head. Then one of the jihadis from the checkpoint was put into the back of their car and they were told to drive to the Isis base. The fighter had a pistol pointed at them the whole time, which was superfluous because he was also wearing a suicide belt. ‘Make a move and I’ll detonate myself,’ he said. ‘We’ll all die together.’

Paul Wood and Lara Prendergast discuss the Syrian crisis:

At the base, the emir, or commander, was so delighted to have two infidel prisoners that he got on to his radio to spread the good news. ‘All units, all units,’ he gleefully proclaimed: ‘We have two journalists. Thanks be to God.’ He ordered them to be handcuffed, blindfolded and taken to jail. It was the start of an ordeal of constant beatings and death threats that came to an end ten months later when the Kurds arranged a prisoner swap. Some time after they arrived in the cell, a new inmate joined them. It was the emir who had ordered their detention. It seems he had been declaring rich local Muslims to be infidels in order to steal their money — but had overplayed his hand and was now in his own jail.

The emir was a Syrian in his late twenties. When the revolution started he had volunteered for the Free Syrian Army. Next, he joined the al-Qaeda group in Syria, the Nusra Front. Finally, he defected to Isis, because they were closer to God, and because they gave him a car and a house. He spent his time in the cells abusing the other prisoners as infidels but mostly ‘all he wanted to talk about was girls’, said the Kurdish journalist. The emir’s story has many familiar elements: the journey from the FSA, through Nusra, to Isis; the greed and corruption of many in the revolution, including those who profess religious motives; and the risible hypocrisy — hilariously exposed by the emir’s sex-obsessed prison talk — of those wrapping themselves in a black flag to dictate the morals of others.

Many Islamic State fighters joined up because Isis were the strongest, richest and most successful group. But now that they look like losers, the defections are gathering pace, hastening the collapse of the ‘Caliphate’ predicted in this magazine in January and which may be starting to happen now. The latest loss is the important town of Manbij. The battle is still going on, but commanders of the advancing Kurdish forces say Isis fighters are shaving off their beards and trying to slip away among groups of refugees. Some have even been captured dressed as women. Only a month ago, according to local activists, Isis had publicly executed a whole family, including two children, for trying to flee.

Of course, even after the caliphate is gone, the so-called Islamic State’s jihad against the West will continue. In fact, as I wrote here in January, its death throes will be marked by more killing in the West, though it seems that the recent horrific attacks in France and Germany were the work of (possibly deranged) individuals, and only later claimed by the Isis leadership. Syria’s war without end will go on, too, because Isis occupies only one corner of a crowded battlefield. Earlier this year, a think-tank produced a handy graphic designed to explain the Syrian conflict. Different coloured lines showed who’s killing whom, who’s arming which side, and whose money keeps the war ticking along. It looked like the world’s most complicated cat’s cradle; it was also reminiscent of a circular firing squad.

The conflict grows steadily more complicated. Take the American offer to Russia of an alliance to carry out joint bombing raids against Nusra, that is to bomb al-Qaeda in Syria. Nusra then cunningly changed their name and announced they were severing the link to al-Qaeda. Many US officials think that is a con. But if the Americans do go ahead and bomb, it will be another example of the United States literally fighting on both sides of the war. Russian military sources recently said one of their helicopters in Syria had been shot down by an American TOW missile. It was supposedly fired by Isis — if so, it’s not clear how they got hold of it — but any of the rebel groups might have launched it. Russia is killing them in large numbers, along with even larger numbers of civilians, as part of its effort to keep President Assad in power.

American policy is still, officially, to depose President Assad. But if they join Russia in targeting the most effective anti-regime rebels, the group formerly known as Nusra, then the Russians will have more bombs left over to drop on the other rebels, the ones the Americans support. The madness extends further. The US airstrikes support the Kurdish militia in Syria, the YPG, because it is the most effective force against Isis. Yet the YPG is in a tacit alliance with the regime, and has found itself in skirmishes with the Arab rebels backed by the Americans. Both are now in a race to occupy territory vacated by Isis fighters as they retreat in northern Syria. And as the US-backed YPG moves through the north, it has come under artillery fire from Turkey, America’s Nato ally. Meanwhile, in the fight against Isis in Iraq, the US finds itself acting as the air force for Shia militias funded and directed by Iran.

It is not just the US that suffers from strategic incoherence. For years, Turkey let Isis keep safehouses and operate rat-lines for volunteers and supplies across its Syrian border. Isis were fighting the Kurds and Turkey’s logic, presumably, was that the jihadis would keep Kurdish nationalism in check. But now Isis suicide bombers are blowing themselves up in Turkey and there may be thousands of jihadi ‘sleepers’ in the country, according to one intelligence source. The Kurds in Syria have anyway managed to establish something that looks very much like their own state, encouraging a resurgence of the bitter conflict between Turkey and its Kurds across the border. (After last month’s failed coup, the Turkish military and security services are now occupied with internal matters rather than their fight with Isis or the Kurds.)

Starting, or escalating, a war with Turkey made no sense at all from the Islamic State’s point of view. Isis is believed to have carried out five to seven attacks in Turkey. The lesson of Afghanistan, and many other conflicts, is that it is almost impossible to defeat an insurgent group that has a rear safe area — yet this is exactly what Isis has denied itself in bringing the war to Turkish soil. It made no sense, either, for Isis to sacrifice so many of its fighters to the battle with Nusra. They have almost identical ideologies — indeed they were one organisation before they split — yet their side-war has often been bloody enough to overshadow the struggle with the regime.

Nusra, as it used to call itself, is coming out on top. According to some reports it has gained 3,000 to 4,000 recruits in northern Syria since spring. This is part of the reason the US proposed an attack, though it’s less than a year since the ex-CIA director and Afghanistan commander General David Petraeus was arguing that elements of Nusra could be peeled off to fight Isis alongside the Americans. If the US bombs now, that is likely to drive Nusra back to al-Qaeda.

The other big beneficiary of the current mess is President Assad. Increasingly, there are moves to rehabilitate him as the alternative to rule by the jihadis. For a long time it has been an article of faith among the dwindling numbers of the ‘moderate’ opposition that Assad incubated the jihadi movement, creating the enemy he needed to unite his own people and win international support. This was in fact exactly what had happened, the commander of one of the biggest Salafi rebel groups in Syria, told me once. He had been in prison before the uprising. He and his cellmates all went on to important leadership positions in Isis, Nusra, and other jihadi groups. They were all freed within weeks of street protests against the regime getting under way.

Some say all this is America’s fault. Firstly, at the start of the conflict, President Obama declared that Assad should go, encouraging many in the uprising to think they had a superpower ally and so victory was inevitable. Secondly, the US then failed to intervene decisively — letting Saudi and Kuwaiti donors put their imprint on the emerging armed groups. People in rebel-held areas did turn to the jihadis in 2013 when the Americans failed to bomb the regime, as President Obama had threatened after the chemical attacks outside Damascus. But the character of the armed uprising was always Islamist, or at least Islamic. The battle cry of every single armed group I met in about a dozen trips inside Syria was not ‘Democracy’ but ‘God is great’. This is one reason why a US training scheme produced ‘only four or five’ rebel fighters despite spending half a billion dollars, as an embarrassed general admitted to Congress last year. (Yes, those figures are correct.)

The US could not have changed the nature of the uprising, though it could perhaps have nudged it in a more moderate direction. This is clearly not going to happen while Obama sees out the last months of his presidency —but even a more engaged US president would struggle with the forces driving the conflict. All sides in the war have been corrupted and degraded by fighting it. Last month there was a report that the US-backed Noureddine Zinki Brigade in Aleppo had beheaded a 12-year-old boy in front of cheering bystanders. The child was said to have been captured while fighting for a pro-regime militia.

Syria’s agony will go on, not just because of big power politics but, more importantly, because so many rebel leaders had nothing — were nothing — before the war and now have everything. One brigade commander made bricks in the sun for a living and now drives a BMW. Two Yazidi sisters told me that the ‘emir’ who bought them as sex slaves had been the village odd job man, who used to beg their father for work. The emir who captured the Kurdish journalist may have ended up in jail, but there are many more like him, for whom war is a business. And business is good.

A US training scheme produced 'only four or five' rebel fighters despite spending half a billion dollars

Paul Wood has spent four years covering the Syrian war for the BBC.