It has been a dramatic, perhaps catastrophic, weekend for Islamic State in Iraq and the Levant. Dabiq in Syria - the town to which Isil attached huge importance as the prophesied site of an apocalyptic showdown between Muslims and "unbelievers" - fell with barely a whimper. Now the assault on Mosul, the group's capital in Iraq, has begun too.
If Isil finds itself in retreat and unable to project the same vision of power and victory as before, the rising numbers of disfranchised fighters seeking to leave its "Caliphate" will only increase. Nor are their places in the ranks certain to be replenished, as the shattering of the group's image as an all-powerful entity which controls a nation with major cities will also reduce its appeal as a destination for new recruits.
Yet the consequences of any Isil defeat are hugely important for the West too - and not exclusively positive. We must be prepared.
In particular, what will happen now to the thousands of foreign fighters who will be suddenly left without a home? Rudderless but with a sense of revolutionary purpose, they will present a menace to security officials around the world for years to come.
The closest precedent is the war in Afghanistan in the 1980s, when mujahideen rallied to fight the Soviet Union. This produced the beginnings of the network that not only developed into al Qaeda, but also created a cadre of warriors who afterwards sensed an opportunity to use their battlefield experience to overthrow regimes in their home countries. In some cases, they sought another struggle to join, be it in North Africa, Southeast Asia, Central Asia, Chechnya, Kashmir or Bosnia. The war's aftermath created clusters of militants with links across the Eurasian continent, North America and Asia - cells that turned into the base for al Qaeda plots for years to come.
In the case of Isil today, there is a risk of such directed cells. Isil has shown a capacity to send fighters back hidden among the refugees coming to Europe. If it is threatened in Iraq and Syria it may step up the number of those "returnees" to establish networks or even launch attacks. Keeping track and understanding this flow, then preventing any plots, will be a major task for European intelligence agencies.
More worrying still, however, may be the threat posed by Arab, South-east Asian, Central Asian, Russian and North African fighters if they start heading home. In some of their home countries, the injection on a large scale of well-trained and battle-hardened fighters could become too much for authorities to cope with. This may lead to instability and violence which in some cases may be targeted against western nationals. In the worst-case scenario, a country may find itself a new base for terror operations, or a new rogue state could be born.
Those are the short and medium-term dangers. The longer-term danger depends not on Isil, but upon our own behaviour. As the militants are pushed back from Mosul, there is the strong possibility that Western attention will drop off once again. Last time the West seemed to score a victory in Iraq, after The Surge in 2007-2008, Western powers rapidly lost attention and withdrew. The result was a sectarian mess that created the perfect environment for Isil to grow. Moreover, no one should be in any doubt that - despite the loss of Dabiq - Isil is still a potent force across the purely notional border in Syria. The brutal civil war there rages on.
Above all, we in the rich world must not take Isil's precipitous loss of territory as an excuse to take our eye off the ball. Of course, the pressure must be kept up on the battlefield. But if we are prevent a resurgence, much more must be done to rebuild communities and cities that have been torn apart.
Without this groundwork, Iraq will sink into the same old sectarianism, and Isil or a successor group will surely emerge. All of this is a long-term struggle that the West has failed to follow through on in the past. We must not make same mistake twice.
Raffaello Pantucci is Director of International Security Studies at the Royal United Services Institute (RUSI) and author of 'We Love Death As You Love Life: Britain's Suburban Terrorists'