THE ISLAMIC State is on the ropes, yet the group may make a comeback. The U.S.-led coalition has driven it from much of its territory in Iraq and Syria, while most of its so-called “provinces” elsewhere in the Muslim world also have lost territory or stagnated. In July, U.S.-backed local forces took Mosul, the Islamic State’s largest stronghold in Iraq, and then in October took the Syrian city of Raqqa, the Islamic State’s capital. The caliphate may soon exist only as an idea. Once the most powerful jihadist group in modern history, the Islamic State is “now pathetic and a lost cause,” claimed Brett McGurk, the U.S. envoy for the anti–Islamic State coalition.

Despite these impressive gains, the United States is not well prepared for the group’s defeat. After losing control of key territory, the Islamic State may repeat the actions of its predecessor when the U.S.-led surge brought Al Qaeda in Iraq to the edge of defeat: go underground, disrupt politics and foster sectarianism; wage an insurgency; and then come roaring back. The United States cannot depend on its partners to counter this cycle, as local allies in Iraq and Syria are unprepared to govern and conduct effective counterinsurgency operations, while the very identity of long-term U.S. allies is unclear as Washington lacks a durable coalition in Iraq, let alone in Syria. Finally, the concepts the Islamic State promulgated are dangerous and may be exploited in the future by the Islamic State or successor organizations. As a result, the Islamic State’s campaign of regional and international terrorism, already maintained at a high level despite the group’s territorial setbacks, will likely continue and perhaps even grow in the near term.

President Donald Trump began or continued several positive counterterrorism policies—but also undertook initiatives that risk aggravating the danger the Islamic State poses. The administration improved relations with important allies like Saudi Arabia and continued the military campaign that began under former president Barack Obama to steadily drive the Islamic State from its strongholds in Iraq and Syria. However, the administration’s anti-Muslim rhetoric and policies will likely alienate some American Muslims, increasing the risk of radicalization and discouraging cooperation between these communities and police and intelligence services. In addition, the administration’s blanket embrace of the Saudi position in the Middle East will heighten sectarianism, which feeds the Islamic State and like-minded groups. Finally, a decline in foreign aid, the State Department budget and the number of national-security personnel diminishes U.S. diplomacy and the United States’ ability to resolve conflicts—all necessary for fighting jihadist groups and preventing them from spreading to new areas. Although many positive changes seem unlikely under the Trump administration, efforts to fight the Islamic State more effectively would include continuing efforts to train allied military and security services (albeit with realistic expectations). The Trump administration and U.S. leaders in general should try to bolster American resilience, which current policies are undermining.

THE ISLAMIC State has steadily suffered a series of defeats in the last two years. Most important, its base in Iraq and Syria has shrunk dramatically. By fall of 2014, the Islamic State controlled much of eastern Syria and western Iraq, including Raqqa, Mosul and Tikrit, and by spring 2015, the group captured Ramadi in Iraq and Palmyra in Syria, while its so-called province in Libya seized Sirte and nearby territory. Since then, a mix of Iraqi government forces, Kurdish militias, local tribal groups and others have pushed the group from major cities in Iraq and Syria. The Islamic State is likely to lose almost all its territory in Iraq and Syria in the coming months.

The so-called Islamic State provinces have also suffered. However, in 2016, U.S.-supported militia groups drove the Islamic State province in Libya from its base around Sirte, dispersing it to southern Libya. Elsewhere, Islamic State provinces demonstrated little dynamism in recent years—a stark contrast to 2014 and 2015 when the group seemed to expand throughout the Middle East. Some Islamic State provinces, like the one in Sinai, are succeeding with a low-level insurgency that includes bloody terrorist attacks, but these have focused on their own societies and governments, not the United States and its allies. Although analysts fret that the Islamic State might relocate—and some fighters will inevitably find a new home—there is no credible substitute for Iraq and Syria as a base, as terrorism analyst Jason Burke contends.

Funding and recruitment also dried up. The Islamic State attracted more than forty thousand foreign fighters; in some months, more than a thousand foreign fighters would join its ranks. In the last year, the number of new foreign volunteers reduced to a trickle, and the organization’s budget, which relies heavily on “taxing” local territory, also declined.

The Islamic State’s decline perpetuates itself. The group appealed to foreign fighters and funders partly by marketing itself as a winner that successfully created an Islamic state with true Islamic governance. Its biggest boasts are now its biggest failures. Fewer foreigners want to join a group incapable of defending the caliphate and clearly losing to the enemies it vowed to vanquish. Additionally, local groups in Iraq and Syria allied with the Islamic State due to its perception of constant success and feared that they would end up vulnerable when the group inevitably triumphed. As the tables turn, even groups that embrace the Islamic State’s ideology have a strong incentive to defect to its enemies.