The reach and ambition of Islamic State shocked the world when what was once a defeated branch of al-Qaeda captured Iraq's second largest city, Mosul, and declared a global caliphate in June of 2014. At its height, IS controlled vast reaches of territory in Iraq and Syria and it, along with other jihadist groups such as Jabhat al-Nusra (now known as Jabhat Fatah al-Sham) attracted more than 30,000 foreign fighters to their cause.
However, Islamic State is now, once again, an enterprise in decline. The so-called caliphate is collapsing under the weight of its own brutality and contradictions, unrelenting Coalition airstrikes, and operations by Iraqi and various Syrian land forces. This should be good news, but the defeat of IS in Iraq and Syria will come at a steep cost: the diffusion of the thousands of foreign fighters drawn to the jihadist cause.
The end of Islamic State does not mean an end to the threat posed by the foreign fighters who have flocked to it and other jihadist movements, but merely represents the end of one phase of a much longer campaign against violent jihadists.
The fighting in Syria and Iraq has helped create the basis for an extensive global network of foreign fighters in much the same way that the war against the Soviet Union in Afghanistan created the basis for al-Qaeda's global networks.
The difference this time is that the jihadist networks will be larger and more lethal than those that emerged from Afghanistan.
IS is also preparing for this next phase. As its territory diminishes, IS supporters are no longer travelling to Iraq and Syria in record numbers and indeed some foreign fighters are starting to leave the territory. IS has also encouraged its Western supporters to carry out attacks where they are.
There is a strong correlation between Islamic State's territorial losses and military defeats with its international attacks. IS has claimed credit for the downing of a Russian airliner in Egypt, attacks against the Brussels airport, simultaneous attacks in Paris, and countless bombings in and around Syria and Iraq in areas just outside its control. Some of these, particularly the Brussels and Paris attacks, featured returned foreign fighters.
There is every indication that these types of attacks will continue.
Given the nature of terrorist networks and the fragmented way in which the armed opposition in Syria in particular has been organised, there is no one model that foreign fighters will adopt after hostilities. Some may stay in Syria and Iraq. Others will seek to continue to fight in the region or elsewhere either as part of a deliberate plan or because they do not wish to face criminal charges at home.
Some will return to their home countries, with or without an intention to conduct attacks. The world will feel the impact of this cadre of trained, experienced and networked foreign fighters for some time to come. And it will be contingent on the international community to work together to minimise the threat.
Closer intelligence co-operation and border protection management will be essential: sharing information is a key element but an aspect states have found difficult in the past, particularly if they do not have already established information sharing protocols.
We should not equate the demise of Islamic State's physical hold on territory with the end of the jihadist threat. Islamic State's new online magazine Rumiyah was released in several languages this week and continues the group's focus on attacks against the West. The edition included specific references to attacks against Australian targets as part of its story eulogising Ezzit Raad, who travelled to and was killed in Syria after finishing his jail term for terrorism offences in Victoria.
These calls are not new, of course, but are a timely reminder the conflicts in Syria and Iraq can't simply be contained there. For the last five years, Western counter-terrorism agencies have focused largely on radicalised individuals going to Iraq and Syria. Now is the time to focus on those coming back.