A day before the battle to expel Islamic State from Mosul began, the group’s propaganda was dealt a potentially significant blow that was quickly forgotten. Turkish-backed Syrian rebels drove Isis out of Dabiq, a small town in northern Syria, where Mohammed Emwazi, the British extremist known as Jihadi John, beheaded Peter Kassig, an American aid worker, declaring: “Here we are, burying the first American crusader in Dabiq, eagerly waiting for the remainder of your armies to arrive.”

With the rise of Isis in 2014, the town served as the centre of its propaganda. This was where Isis promised a final showdown between the forces of good and evil, an epic battle supposedly foretold by Islamic prophecies in the seventh century. Isis named its main propaganda magazine after the town.

To depict its story as a coherent one foreseen by its visionary founders, each of the magazine’s editions began with a quote from Abu Musab al-Zarqawi, who founded the group in Iraq in 2004: “The spark has been lit here in Iraq, and its heat will continue to intensify – by Allah’s permission – until it burns the crusader armies in Dabiq.”

But Dabiq was recaptured by Sunni militants. The expulsion of Isis from the town was an opportunity to deal its propaganda a double blow, not just because of the failed prophecy but that it was defeated by the very population that Isis claims to represent, on whose behalf it is fighting the world. Isis quickly revised the Dabiq prophecy, saying it still applied but its time had not yet come. Isis moved the goalposts, figuratively as well as literally – fleeing fighters reportedly removed the town name’s signs and took them away.

We have been fighting for each metre. And when I say we have been fighting for each metre, I mean it literally. Maj Gen Sami al-Aradi

The opportunity to undermine the Isis narrative was lost and people barely remember Dabiq today. A day after its defeat in Dabiq, Isis began to depict Mosul as the site of the epic battle instead. And from a military perspective, as US officials would readily acknowledge, the Mosul battle was nothing like they have seen against a terrorist group. It was the largest campaign in Iraq’s recent history, with a force of about 60,000 mobilised against Isis deploying formidable US firepower. For both sides, it was bloody and intensive.

Maj Gen Sami al-Aradi, a commander of Iraq’s special forces, told the New York Times: “I have participated in all of the battles of Iraq, but I’ve never seen anything like the battle for the old city. We have been fighting for each metre. And when I say we have been fighting for each metre, I mean it literally.”

But Iraqis emerged victorious. Mosul, Isis’s most populous and symbolic stronghold, was liberated. The Great Mosque of al-Nuri in Mosul, from which Abu Bakr al-Baghdadi gave his ascension speech as “caliph”, was recaptured after his fighters blew it up to deny the government the possibility of adding insult to injury by announcing the liberation of the mosque.

An armoured vehicle sits among the ruins of the Great Mosque of al-Nuri, destroyed by Isis, in Mosul. Photograph: Anadolu Agency/Getty Images

The group is also projected to lose its second pillar, Raqqa in Syria, by the end of this year. The caliphate is falling apart.

In this context, the common question has been: what comes next? Where is Isis heading after Mosul and Raqqa? How much of a threat will a post-caliphate Isis be to the region and the world?

The consensus, by observers and politicians alike, is that Isis is far from over. But little has been said about the extent of the damage caused by and to the organisation. Four aspects can help provide clarity:

■ Isis has lost the caliphate but it has gained a transnational organisation it did not have three years ago. Largely an Iraq-focused organisation, al-Qaida in Iraq, whose founders came from various jihadist battlefields, was a localised group until it expanded into Syria in 2013 and became Islamic State in the summer of 2014. Since then, it has sought to develop branches and cells across the region and beyond.

Isis is arguably a fully fledged international group vying to reclaim the mantle of global jihad from al-Qaida. The world today faces a second global jihadist threat that it did not face before 2014, a threat whose model operates differently from that of al-Qaida. Isis, for example, emphasises sectarian jihad against Shia Muslims, Coptic Christians and other minorities in a way that al-Qaida does not.

■ Isis is still stronger than it was before its military advances in June 2014. It became more powerful as it controlled territory, something that enabled it to make money and recruit from local populations based on its military success. It has been significantly weakened compared with the height of its strength after it had seized one third of Iraq and half of Syria.

But compared with what it used to be before then, however, Isis is significantly stronger, larger and a greater threat to both Iraq and Syria. As a local insurgent group, Isis now has a bigger network since it expanded into various territories in the two countries. Its internal structures have been minimally damaged, if not strengthened. The group still controls several strongholds in both countries, and Iraqi forces continue to be unable to recapture those strongholds without close US air support – an indication that the group is still a capable military force; Isis is likely to continue to hold on to some territory well into the fourth anniversary of its so-called caliphate this time next year. US officials expect the fight in Raqqa to drag on until the end of the year and the complex operation to expel it from Deir Ezzor will take about the same time after that. The US is at loggerheads with the Syrian regime and its Iranian and Russian allies over who fights in Deir Ezzor or in which areas.

■ The Isis strongholds in Anbar, while possibly easy to recapture, are likely to continue to be hideouts from where the organisation can operate and launch attacks. These border areas, which can be described as the group’s “third capital” after Mosul and Raqqa, are central to its post-caliphate strategy of hit-and-run operations. They were also where Isis began its push into much of Iraq and Syria in 2014.

■ Finally, it is worth bearing in mind that Isis has cost both Iraq and Syria dear in terms of economic development. While its defeat will bring respite to affected communities and encourage hopes of a new beginning, Isis brought massive destruction both to the infrastructure and the social fabric of many areas. Euphoria will eventually wear off and the dismal reality of conflicts and tensions in Iraq and Syria will again begin to surface.

The misplaced optimism which accompanies the fatigue that naturally follows wars can lead to miscalculations. People are overwhelmingly relieved to be freed from Isis, but the reality that allowed its rise in 2014 remains, and has even worsened. And yet, a return to the same cycle is not inevitable. A window of opportunity for communities to move away from the cycle of violence exists, but this is not an invitation for meddling by national politicians and government-affiliated militias, nor is it a permanent one. A return to the cycle is a real possibility.

As a threat, Isis has been contained to a large degree. The prospect of an uncontrollable expansion in the wake of its announcement of a caliphate is remote. This does not mean that Isis is finished. It does mean, though, that the world now has the chance to think more clearly about the fundamental causes of such groups and how to uproot them.

Extremist groups tend to be more energetic than governments in the way they exploit local grievances. Isis has also proved more adaptive than security forces in facing changing realities. It quickly salvaged its propaganda when it lost Dabiq and moved the goalposts. Dabiq was a lost opportunity. Mosul too was a lost opportunity.

As a military operation, the Mosul battle was impressive. For the first time, peshmerga forces fought alongside Iraqi forces, and sectarian militias were largely kept out of fighting inside the city. But the operation could achieve more than that. Both Mosul and Raqqa provide an opportunity, given the contentious political issues surrounding the two cities, to draw a clear political road map for a new Iraq and Syria. In both cities, the US and allied countries have a chance to play a big part in the conversation about what should come after they help liberate such areas from Isis. Instead, the fear is that the same issues of sectarian division and government corruption and incompetence will prevail – the same circumstances that allowed the rise of Isis in the first place.

Hassan Hassan is co-author of New York Times bestseller Isis: Inside the Army of Terror, and a senior fellow at the Tahrir Institute for Middle East Policy. @hxhassan