First, a bit of good news about the long-term prospects of the Islamic State: It has no allies and its vastly overmatched conventional military capabilities are coming under pressure from all sides. It has lost more than a quarter of its territory and five of the ten population centers it controlled after its high-water mark in the summer of 2014. But perhaps the Islamic State’s greatest weakness is the strategic incoherence of its attempting to simultaneously run a proto-state in Iraq and Syria while also exporting a global jihad.

In the chaotic aftermath of Russia’s 1917 October Revolution, Bolshevik leaders similarly attempted to re-establish control over their country while promoting communist revolution in Europe and beyond. But these copycat uprisings quickly failed, and “Socialism in One State” became official Soviet policy by 1924. From then on the Soviet Union operated more like a traditional state than a revolutionary one.

For its part, the Islamic State is moving in the opposite direction. Its governance model is failing and it lacks revenues to sustain even minimal service provision. As a result, it is slowly shedding its state, a trend which could well accelerate if the Iraqi campaign to retake Mosul is successful in the months ahead.

Now, the bad news: Even as the Islamic State slowly fails in the face of increased military pressure, the threat posed by the group’s global ideology is increasingly distinct from its institutional base in Iraq and Syria. Amid a steady stream of battlefield defeats, the Islamic State’s reach has expanded, with branches now operating in Egypt, Libya, Yemen, and elsewhere. A more diffuse decentralized terror network might be less capable of executing the coordinated attacks across six sites that killed 130 people in Paris in November 2015. However, it may also be more resilient and better positioned to survive the eventual loss of the Islamic State’s self-proclaimed caliphate.

This evolution highlights a tension inherent in Western military and counterterrorism efforts. As “foreign fighter” flows to Iraq and Syria have significantly dried up, the incidents of terrorism in Europe and North America have actually increased. In 2014, Omar Mateen and Mohamed Lahouaiej-Bouhlel might have traveled to Syria or Iraq to fight and die. In 2016 they were the perpetrators of the June 12 Orlando nightclub shooting and the July 14 Nice Bastille Day attack.

Although the incidence of European terrorism remains lower than at its peak in the 1970s and 1980s, when waves of political violence swept through Europe (think the Irish Republican Army, the Basque ETA, and Italian neo-fascists), the political fallout of terrorism by Islamic extremists seems likely to be more severe given the upsurge in nativist politics and a social media environment prone to hysteria.

The Islamic State has now claimed responsibility for attacks in more than 20 countries in the last two years, no matter how tenuous were their operational connections. And Iraqi and American-led coalition military successes against the Islamic State in Iraq may have removed any lingering restraints the group might have had to conducting attacks abroad for fear of eliciting a stronger international response.

This is not an argument for inaction in Syria. The Syrian civil war is causing unfathomable levels of human suffering, and is the main catalyst for the global rebound in terrorism by extremist Islamist groups. The fallout of the Syrian refugee crisis is exacerbating political instability as far away as Europe, and the Assad regime’s indiscriminate use of barrel bombs may well be the Islamic State’s most effective recruiting tool.

Resolving this conflict is the most urgent priority facing global leaders. Yet a political settlement in Syria and the removal of the Islamic State’s safe havens in Syria and Iraq, no matter how essential, will not end the metastasizing threat the group poses. When self-radicalized individuals in the United States or France, faced with a near-endless array of soft targets, can pose disproportionate security and political threats, the virtual caliphate has become as dangerous as the physical one.

There are, of course, additional measures to mitigate this ideological threat over time: improving international intelligence cooperation; increasing attention to the alienation of disaffected and marginalized Muslim communities; addressing sectarian divisions in the Middle East; and reducing anti-Muslim political rhetoric in North America and Europe. But it goes without saying that these are long-term challenges, not quick fixes. Indeed, some of the proposals for dramatic military escalation against the Islamic State’s base in Iraq and Syria would probably result in more global terrorism rather than less.

Meanwhile, we need to prepare ourselves for the likelihood that, whatever happens in Syria, the scourge of the Islamic State will be with us for some time to come. Even more importantly, we need determination not to allow it to undermine the fabric of our own societies.