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.

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.

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.

But one should not let such possibilities to run riot and pretend that the old al-Qaeda formula of making war – with suicide attacks as acts of faith – has the destructive power it once did. President Trump is largely right in his claims that Islamic State is destroyed – even if he is grossly, even ludicrously, inflating his own role in its demise.