“The dream of a liberation is now a reality,” Iraqi Prime Minister Haider al-Abadi proclaimed last week, when his forces drove ISIS from a few final strongholds. Abadi's declaration of victory did not seem unwarranted. After three years, Iraqi and Kurdish fighters, backed by an 80-country U.S.-led coalition, have reclaimed all of the territory ISIS once controlled in Iraq and the key cities it held in Syria. The Islamic State no longer has much of a claim to calling itself a state at all.

But the victory is incomplete—and not just when it comes to the challenges of ISIS-inspired lone-wolf attacks, foreign fighters returning home from Iraq and Syria, and the persistence of ISIS franchises elsewhere. While such concerns are real, a more dangerous scenario also deserves some attention: ISIS could resurrect its caliphate where it was born, in Iraq and Syria. It has been planning for such a resurrection since at least 2016, and quietly preparing since well before losing Raqqa in October.

Most ominously, ISIS has a tried-and-true playbook for bringing itself back from near death. Just a few years ago, it managed to resurrect itself after apparent defeat. And the history of that resurrection should serve as a warning of what may be coming now.

After the Surge

What is ISIS today was founded by Abu Musab al-Zarqawi in 2003. (It has gone by several different names over the years.) Its organization has been changing according to need ever since: from nascent underground jihadist movement to guerrilla insurgency to proto-state to state-like caliphate whose territorial expansion sprawled across much of Iraq and Syria. But this change has not been linear. ISIS has expanded and contracted as circumstances dictated while pursuing an end-state goal of restoring a Muslim caliphate as glorified in its theological texts. After losing its twin capitals, Mosul and Raqqa, ISIS is contracting once again. But its strategic aims have not changed.

In recent statements, ISIS leaders have drawn an explicit analogy between its situation today and its similarly dire plight in 2008, when it resorted to guerrilla insurgency and terrorism and thereby set the stage for its dramatic takeover of much of Syria and Iraq a little more than five years later. Captured internal memos and administrative documents show that, after the U.S.-led surge and the Sons of Iraq local security-force program displaced the group from central and western Iraq, remaining ISIS members fled and went into hiding in and around Mosul. Although forced underground, they used the Mosul area as a base for organizing, recruiting, and financing cells across Iraq. ISIS leaders, meanwhile, deployed the group's Emni security service to assassinate Sunni political opponents—especially local forces, including the Sons of Iraq and police, that threatened ISIS's operational security and hold on the politics of Sunni Arabs. They also worked to co-opt Sunni Arab politicians in the Mosul area and in Baghdad, promising diminished violence against important economic sectors in exchange for political and monetary support.

All of these elements worked toward a basic goal: to stoke Sunni-Shiite conflict and thereby make a large swath of Iraqi Sunnis see ISIS as their only hope. Emni terrorized local rivals and businesses into helping rebuild ISIS's capacity and incited the paranoid Shiite-dominated Iraqi government to overreact to the specter of a Sunni terrorist threat—and thereby reignited the sectarian conflict that helped give rise to the group in the first place, following the 2003 U.S. invasion. While a 2010 U.S.-Iraqi raid wiped out a cohort of top figures from the group, a new leader, Abu Bakr al-Baghdadi, carried this strategy forward, while working underground to eliminate competition and to rebuild ISIS manpower by breaking fighters out of prison. And when the Arab Spring came and civil unrest grew in 2011 and 2012, ISIS was quick to send agents into Syria to establish a new base of operations. The stage was thus set for ISIS's rapid 2014 takeover of territorial holdings as large as Great Britain.

The Revival Next Time

Now that the U.S.-led campaign has achieved its main objective, ISIS faces severe challenges in Iraq and Syria. It lacks meaningful conventional military capacity and manpower. Its military units have been largely destroyed or have simply fallen apart due to infighting and waves of surrenders.

ISIS is working to provoke the Iraqi government to crack down on Sunni Arabs—its core demographic group for recruiting and its base for political legitimacy.

But ISIS overcame eerily similar challenges in the late 2000s. Despite having lost nearly all of its territory, it still has a highly committed cadre at its core, including elements of the Emni, as well as experienced administrative officials, the glue of the ISIS organization from top to bottom. And it has wasted no time implementing a shift from a territorial “caliphate” to terrorism and insurgency. This new campaign has already begun to bear fruit. ISIS has mounted successful attacks in areas the U.S.-led coalition previously declared liberated, such as Fallujah and Ramadi, as well as other areas that ISIS did not control even at its peak, such as Baghdad and Diyala Province. As it did in 2010, ISIS is working to provoke the Iraqi government to crack down on Sunni Arabs—the group's core demographic group for recruiting and its base for political legitimacy.

When it declared its caliphate in 2014, ISIS stated that its strategy was to “remain and expand.” Its new strategy is closer to one of recuperation. While some fighters will continue to flee Iraq and Syria—either to join ISIS franchises elsewhere in Asia or Africa or to return home—others will remain, with the objective of exploiting favorable conditions for terrorism and insurgency. And it is in this territory where ISIS's local knowledge and intelligence networks give it a good chance to re-infiltrate key areas and to operate clandestinely.

ISIS's prospects for successful resurrection in Iraq and Syria hinge on three main factors: the quality of governance and legitimate Sunni Arab political leadership in Sunni areas; the continuation of sectarian politics dominated by Shia groups; and the capacity of institutions to begin reconstruction of Sunni-dominated areas destroyed in the war against ISIS. In Iraq, the proximate cause of ISIS's last resurgence was a combination of local political corruption and malign neglect and discrimination by the Shiite-dominated national government. In Syria, meanwhile, the security challenges will likely die down for the time being, since many ISIS fighters there have fled to remote safe havens in the desert. But if a security vacuum reemerges—a real possibility given the complex array of forces in Syria's civil war—and the Kurdish anti-ISIS coalition begins to break apart, many of those fighters could quickly return.

Whether or not ISIS can be defeated for good depends most of all on Iraqis and Syrians.

Whether or not ISIS can be defeated for good depends most of all on Iraqis and Syrians. Yet outside actors have a role to play. While large-scale military operations from here forward will yield little, the United States and its coalition partners can help Iraq to build the law-enforcement and intelligence capabilities necessary to end insurgencies and terrorist groups. They can also help disrupt ISIS's international command and control by identifying and interdicting couriers and monitoring electronic communications in Iraq. And a lasting U.S. presence in Iraq would allow them to sustain a more targeted intelligence-led campaign against ISIS leaders who have gone underground in Iraq and Syria. It would also counterbalance Iranian influence in Iraqi security affairs, which could help head off another wave of anti-Sunni sectarianism in Baghdad. Ultimately, the development of a stable, non-sectarian Iraqi state would do more than anything else to ensure that the playbook ISIS used last time does not help it rise again.

Benjamin Bahney is an adjunct analyst and Patrick B. Johnston is a senior political scientist at the nonprofit, nonpartisan RAND Corporation.

This commentary originally appeared on Foreign Affairs on December 15, 2017. Commentary gives RAND researchers a platform to convey insights based on their professional expertise and often on their peer-reviewed research and analysis.