Up to its dying days the self-declared Islamic State has retained the ability to top the news agenda, even as its fighters were losing their last battle for bomb-shattered villages in the deserts of eastern Syria. When their spokesman promised retaliation for the massacre of Muslims in the Christchurch mosques his threat was taken seriously.

Given the record of Isis atrocities it is not surprising that nobody can discount its ability to exact revenge through existing adherents, new converts or those using its name to spread terror. This is not just western paranoia: in Syria and Iraq people speak continually of Isis sleeper cells waiting to emerge and exact revenge.

There is a largely sterile debate about whether or not Isis – whose territory once stretched from the outskirts of Baghdad to the hills overlooking the Mediterranean – is dead and buried, as Donald Trump claims. Could it be reborn if the pressure against it is relaxed? The answer is simple enough: Isis is defeated as a state apparatus that once ruled eight million people, but it can persist as a terrorist and guerrilla organisation.

I was in Baghdad in June 2014 when Isis was advancing south towards the capital, capturing cities and towns like Tikrit and Baiji with scarcely a shot being fired. The rout of the Iraqi army seemed total and for several days there was no defensive lines between us and Isis advance patrols. As many as 1,700 Shia air force cadets were massacred amid the ruins of Saddam Hussein’s old palaces on the banks of the Tigris river near Tikrit.

Timeline of the Isis caliphate Show all 19 1 /19 Timeline of the Isis caliphate Timeline of the Isis caliphate ISIS began as a group by the merging of extremist organisations ISI and al-Nusra in 2013. Following clashes, Syrian rebels captured the ISIS headquarters in Aleppo in January 2014 (pictured) AFP/Getty Timeline of the Isis caliphate Abu Bakr Al-Baghdadi declared the creation of a caliphate in Mosul on 27 June 2014 Timeline of the Isis caliphate Isis conquered the Kurdish towns of Sinjar and Zumar in August 2014, forcing thousands of civilians to flee their homes. Pictured are a group of Yazidi Kurds who have fled Rex Timeline of the Isis caliphate On September 2 2014 Isis released a video depicting the beheading of US journalist Steven Sotloff. On September 13 they released another video showing the execution of British aid worker David Haines Timeline of the Isis caliphate The US launched its first airstrikes against Isis in Syria on 23 September 2014. Here Lt Gen William C Mayville Jnr speaks about the bombing campaign in the wake of the first strikes Getty Timeline of the Isis caliphate Isis militants sit atop a hill planted with their flag in the Syrian town of Kobani on 6 October 2014. They had been advancing on Kobani since mid-September and by now was in control of the city’s entrance and exit points AFP/Getty Timeline of the Isis caliphate Residents of the border village of Alizar keep guard day and night as they wait in fear of mortar fire from Isis who have occupied the nearby city of Kobani Getty Timeline of the Isis caliphate Smoke rises following a US airstrike on Kobani, 28 October 2014 AFP/Getty Timeline of the Isis caliphate YPG fighters raise a flag as they reclaim Kobani on 26 January 2015 VOA Timeline of the Isis caliphate Isis seized the ancient Syrian city of Palmyra on 20 May 2015. This image show the city from above days after its capture by Isis Getty Timeline of the Isis caliphate Kurdish forces are stationed on a hill above the town of Sinjar as smoke rises following US airstrikes on 12 November 2015 AFP/Getty Timeline of the Isis caliphate Kurdish forces enter Sinjar after seizing it from Isis control on 13 November 2015 AFP/Getty Timeline of the Isis caliphate Iraqi government forces make the victory sign as they retake the city of Fallujah from ISIS on 26 June 2016 Getty Timeline of the Isis caliphate Iraqi forces battle with Isis for the city of Mosul on 30 June 2017 AFP/Getty Timeline of the Isis caliphate Members of the Iraqi federal police raise flags in Mosul on 8 July 2017. On the following day, Iraqi prime minister Haider Al Abadi declares victory over Isis in Mosul Getty Timeline of the Isis caliphate Members of Syrian Democratic Forces celebrate in Al-Naim square after taking back the city of Raqqa from Isis. US-backed Syrian forces declare victory over Isis in Raqqa on 20 October 2017 after a four-month long campaign Getty Timeline of the Isis caliphate Female fighters of the Syrian Democratic Forces celebrate in Al-Naim Square after taking back the city of Raqqa from Isis. US-backed Syrian forces declare victory over Isis in Raqqa on 20 October 2017 after a four-month long campaign AFP/Getty Timeline of the Isis caliphate Trucks full of women and children arrive from the last Isis-held areas in Deir ez-Zor, Syria in January 2019 They were among the last civilians to be living in the ISIS caliphate, by this time reduced to just two small villages in Syria’s Deir ez-Zor Richard Hall/The Independent Timeline of the Isis caliphate Zikia Ibrahim, 28, with her two-year-old son and 8-month-old daughter, after fleeing the Isis caliphate, on Saturday 26 January 2019 Richard Hall/The Independent

Isis had 100 days of stunning victories in Iraq and Syria but its emirs were never to reach the same level of success again. Instead of focusing all their forces on seizing Baghdad, they moved north and attacked the autonomous and near independent Iraqi Kurdish enclave. The US and its allies started using their devastating air power. If Isis ever had a chance of complete victory, it came and went very quickly.

The success of its blitzkrieg tactics in 2014 depended in part on Isis’s ability to spread terror through the internet by broadcasting its atrocities. Iraqi families would watch them and tell their soldier sons to desert the army and keep out of the fighting. The unexpected capture of Mosul in 2014 gave the impression to many Sunni Arabs in Iraq and Syria that the forces of the newly declared caliphate were divinely inspired. Isis commanders certainly believed this.

But now with obliteration on the battlefield Isis can no longer make any convincing claim for divine inspiration or support. One of the great attractions of Isis – that it had almost magical powers guaranteeing victory – has gone. For the eight million Iraqi and Syrians whom Isis once controlled, its rule brought nothing but death and destruction. Almost all of Raqqa, its Syrian de facto capital, and much of Mosul, its Iraqi counterpart, are in ruins. Tens of thousands of Sunni Arabs in both countries have died in the relentless US-led bomb and artillery bombardments that finally overwhelmed Isis defences.

But could the thousands of dispersed Isis fighters that the Pentagon says are hiding out in the vast deserts and semi-deserts between Syria and Iraq reorganise and stage a convincing counter-attack? After all, the US “Surge” in Iraq in between 2007 and 2009 was trumpeted at the time as marking the final defeat of al-Qaeda in there, which was Isis under another name. Isis commanders are reported to draw inspiration from that period, arguing that they have come back before and they will do so again.

It is not very likely that favourable circumstances will once more combine in such a way that Isis could relaunch itself. It has lost the advantage of surprise and has too many enemies who may not like each other but know what Isis can do given half a chance. In 2014 it enjoyed a certain tolerance and even support from Sunni states like Turkey, Saudi Arabia and Qatar which is no longer there.

But this not quite the same as saying that Isis is finished. The deserts of Syria and Iraq are vast and impossible to police in their entirety. Occupation forces, be they Kurds in Raqqa or Iraqi Shia troops in Sunni parts of Iraq, are resented and often hated by Sunni Arabs and Isis could benefit from their disaffection. And even if Isis does not regain such popularity as it once enjoyed in these places, its reputation for homicidal fury means that it does not have to do very much to spread terror.

It has lost the advantage of surprise and has too many enemies who may not like each other but know what Isis can do given half a chance Patrick Cockburn

Isis as Isis has probably had its day. But could it transmute into something else? The defeat of Isis does not mean the defeat of al-Qaeda of which Isis was only a single clone. In north-west Syria Hayat Tahrir al-Sham (HTS), despite several changes of name, has been for over a year the largest jihadi or al-Qaeda type movement in the country. In western Idlib, northern Hama and western Aleppo provinces it has displaced other armed opposition groups. It now may have as many as 50,000 fighters and control three million people. HTS might also establish itself as an ally of Turkey in northern Syria which would allow the al-Qaeda brand to live on.