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.

The Islamic State recognizes its own pitiful position. As the group lost more of its strongholds, its rhetoric shifted to dismiss the importance of territorial control. Instead, the Islamic State emphasized the concept of a caliphate as the driving force behind the group’s success. Abu Muhammad al-Adnani, the Islamic State’s spokesman and senior operational figure, stated in a May 2016 recorded message,

“O America, would we be defeated and you be victorious if you were to take Mosul or Sirte or Raqqa? . . . Certainly not! We would be defeated and you victorious only if you were able to remove the Quran from Muslims’ hearts.”

Like so many other Islamic State leaders, al-Adnani is now dead.

AS THE Islamic State crumbles, its leaders will try to continue fighting rather than surrender. They plan to regroup, maintain their relevance and eventually resurge, through a mix of international and regional terrorism and local insurgency, while keeping their cause alive.

The Islamic State is not a stranger to defeat: it emerged out of Al Qaeda in Iraq, which for several years was on death’s door. In June 2010, Gen. Ray Odierno, then the commander of U.S. forces in Iraq, noted that in the last ninety days U.S. and Iraqi forces had “either picked up or killed 34 out of the top 42 Al Qaeda in Iraq leaders.” The two top Al Qaeda in Iraq leaders died in a firefight that year. By 2011, CIA director Leon Panetta declared, “we’re within reach of strategically defeating al-Qaeda.”

In response, Al Qaeda in Iraq focused on terrorism—in Iraq, not abroad—to stay relevant and to intimidate its enemies. It waged a campaign of assassination against opposing tribal leaders and other Sunnis who cooperated with the Iraqi government, killing more than 1,300 Iraqi leaders from 2009 through 2013. Due to terrorism and local killings, many Iraqis distrusted their government to secure peace and feared openly defying the jihadists. Al Qaeda in Iraq’s patience paid off: over time, the Iraqi government stepped up discrimination against Sunnis and the Syrian Civil War offered a sanctuary across the border. Taken together, these two factors allowed the group to rebuild.

The Islamic State will try to repeat this success. Al-Adnani referred to a “retreat into the desert” to rebuild forces in order to prepare for upcoming battles. This mirrors jihadis’ relocation to remote areas along Iraq’s borders after the 2007 U.S. surge.

Unfortunately, both Iraq and Syria offer promising areas for a rebirth. In Iraq, the government in Baghdad repeatedly implemented policies that discriminated against Sunnis while lacking the strength or support necessary to impose order on an unhappy population—in other words, it cannot coerce, and it seems unwilling to coopt. Shia militias are occupying many Sunni areas where the Islamic State once held sway. Already the Baghdad government is exchanging fire with Kurdish forces. Shia militias are committing abuses against local Sunnis in areas they conquered from the Islamic State. Revenge killings are common.

In Syria, the situation is even worse, with the regime of Bashar al-Assad committing unspeakable atrocities against Sunni Muslims. Tribes, Kurdish groups and other local actors that have worked with America against the Islamic State often regard each other as enemies, or at least have different interests, which will inhibit their ability to cooperate against Islamic State remnants. As their shared enemy declines and the competition for local power increases, these groups are more likely to war against each other. As such, the Islamic State will likely find many openings to exploit, allowing it to relieve pressure and ensure at least some sanctuary. In the scramble for power, many local groups may even shift from enemy to temporary ally.

To defeat the Islamic State as an underground insurgency, someone must develop good governance in its former territories in Iraq and Syria, convincing locals to help uproot the group—an unlikely feat for which there are no credible volunteers. Unlike its previous revival, the Islamic State now has two countries where it can exploit problems, as opposed to just Iraq in the past.

The Islamic State will probably further regionalize the conflict and seek opportunities beyond Iraq and Syria. Already the group regards Iraq and Syria as one theater, shifting assets between the two countries depending on its perceived dangers and opportunities. The group also maintains an extensive network in Turkey, and has attacked Jordan, Lebanon and Saudi Arabia, among other countries. The Islamic State will probe these areas for weaknesses, using its operatives and local supporters to conduct attacks and develop an enduring presence.

Most troubling for the long term, the Islamic State has nurtured the flame of jihad around the world. Even as the group declines, the ideas it champions—the necessity of a caliphate, the glory of brutality and the evil of Western states—have spread further, as the staggering volume of foreign fighters suggests. The Islamic State’s propaganda is extensive and almost ubiquitous. It, or would-be successor organizations, will try to harvest the ideas that the early Islamic State leaders planted.

The Islamic State will likely continue, and may even focus on, terrorist attacks in the West. In 2015, Paris suffered the worst terrorist attack on French soil in history when Islamic State gunmen and suicide bombers killed 130 people. France and other European states saw smaller attacks that year and the next, and by October 2017, five attacks linked to or inspired by the Islamic State targeted the United Kingdom—its most lethal year in terrorism since 2005. These high-profile attacks allow the Islamic State to maintain relevance to would-be and current supporters, convincing them to fight for the group despite its setbacks in Iraq and Syria. The attacks also signify revenge for the group’s tremendous losses. Although U.S. efforts to destroy the Islamic State’s havens hinder the group’s ability to carry out sophisticated attacks, some attacks involve an Islamic State facilitator who helps recruit or directs the attacker, but does not provide elaborate operational support. Many of these attacks are low-tech but quite bloody: the Bastille Day attacker in Nice in 2016, for example, killed eighty-six people by driving a truck through a crowd.

Internal dynamics make Europe a particularly likely target, and in the short term the terrorism threat may grow as the caliphate collapses. The Syrian conflict has attracted over six thousand European volunteers. Some of these European foreign fighters will die and some will stay in the war zone, but some will also likely return to their home countries. One EU official estimates that approximately 1,500 will return. A fraction of those who return home may commit terrorist attacks or recruit locals to join the cause. The potential size of that fraction is unclear, but even a small percentage out of 1,500 can frustrate local police and security services. Europe contains more radicalized Muslims relative to their overall population, as suggested by the dramatically higher number of foreign fighters from European states. In addition, many European Muslims integrate poorly into their broader communities, which discourages them from cooperating with local intelligence and law-enforcement services. Finally, European intelligence services vary in skill: some, including those of France and the United Kingdom, are highly skilled, while others, such as Belgium’s, are under-resourced and less capable of responding to terrorism threats. Fortunately, with heavy U.S. prodding and support, European states have improved intelligence cooperation and otherwise tightened their defenses. But this will remain a long-term challenge.

IN COMPARISON with Europe, the Islamic State poses a more manageable threat to the U.S. homeland. Since the September 11 attacks, ninety-seven Americans have died in jihadist-related attacks in the United States (the figure was ninety-five until the October 2017 truck-ramming attack in New York City, which killed two Americans and six foreign visitors). The two deadliest attacks, in San Bernardino in 2015 and in Orlando in 2016, that together killed sixty-three Americans, involved individuals who claimed some allegiance to the Islamic State but acted independently of the group—often referred to as “lone wolves.” Although any death from terrorism is deplorable, the number of American deaths in the U.S. homeland—ninety-seven—is far lower than many experts, both inside and outside of government, predicted.

Multiple factors likely explain this relatively low level of violence. First, senior U.S. officials overestimated the number of radicals in the United States after 9/11 when they spoke of thousands of jihadist terrorists in the United States. Second, the American Muslim community regularly works with law enforcement, leading to many arrests. As former FBI director James Comey explained,

“They do not want people committing violence, either in their community or in the name of their faith, and so some of our most productive relationships are with people who see things and tell us things who happen to be Muslim.”

“Lone wolf” attacks will likely continue. The trend towards “lone wolf” attacks has grown: although the absolute number of attacks remains low, the scholar Ramon Spaaij found that the number of “lone wolf” attacks since the 1970s grew by nearly 50 percent in the United States and by more than 400 percent in the other countries he surveyed. The Internet and social media explain part of this increase, as both aid the Islamic State in inspiring individuals to act in its name. The October 2017 attack in New York was lifted straight out of the Islamic State’s propaganda organ Rumiyah, which called for using vehicles to mow down pedestrians and then for the attacker to exit and continue to attack. Would-be fighters who do not travel pose a danger as well: according to one 2015 study of the terrorist plots in the United States, 28 percent of returned foreign fighters participated in a plot, but a staggering 60 percent of those who considered but did not attempt to travel became involved in a terrorist plot. As travel to Iraq and Syria loses its luster or becomes infeasible, frustrated jihadists might attack at home. As one French jihadist told the scholar Amarnath Amarasingam, “We believe that even a small attack in dar ul-kufr [the land of disbelief] is better than a big attack in Syria. As the door of hijrah [going to the Islamic State] closes, the door of jihad opens.” Over time this frustration will decline, as would-be fighters no longer have firsthand contact with friends or family who went to fight, but the short-term danger is quite real.

Although the Orlando attack suggests that “lone wolf” attacks can be bloody, most “lone wolves” are incompetent; they are unlikely to succeed compared to trained foreign fighters who return to their home countries. But “lone wolves” have a strategic impact by altering politics in the United States and Europe, thus shattering the relations between Muslim and non-Muslim communities that are so vital to counterterrorism and to democracy itself. “Lone wolf” attacks increase Islamophobia in the West. After the attacks in Paris and San Bernardino, concerns about terrorism spiked. In the weeks following the Paris attacks in November 2015, London’s Metropolitan Police Service announced that attacks targeting Muslims had tripled. Meanwhile, in the United States, assaults against Muslims have increased to nearly 9/11-era levels.

This Islamophobia can also begin a dangerous spiral. As communities become suspect, they withdraw into themselves and become less trustful of law enforcement, which results in providing fewer tips. In contrast, if a community has good relations with the police and society, fewer grievances exist for terrorists to exploit and the community is more likely to point out malefactors in their midst. Even though he was never arrested, the attacker in Orlando came to the FBI’s attention because a local Muslim was concerned by his behavior and reported him.

Such problems risk fundamental changes in politics and undermine liberal democracy. Far-right movements are growing stronger in several European countries. In the United States, Islamophobia and fears of terrorism—despite the less-than-anticipated number of attacks on U.S. soil since the 9/11 attacks—have fueled the rise of anti-immigrant politics.

THE TRUMP administration continued the Obama administration’s military campaign against Islamic State forces in Iraq and Syria, and has loosened restrictions on military commanders and deployed additional forces to Syria—nearly doubling the number of previously deployed forces in the fight for Raqqa. Additionally, the administration has maintained the coalition of states and local actors that the previous administration cobbled together. Furthermore, the aggressive global intelligence campaign begun under President George W. Bush and continued under Obama remains robust. Taken together, such efforts have hindered Islamic State operations and steadily forced it underground.

In his first year in office, however, the president has taken several steps that may impede the struggle against jihadist terrorism. First, in his campaign rhetoric and through actions like Executive Order 13769 (the so-called “Muslim ban”), the Trump administration demonized American Muslims and damaged relations between religious communities—a traditional source of American strength, pride and values. Such actions increase the allure of the Islamic State and other groups claiming that the West is at war with Islam, while also adding credibility and legitimacy to their ideas. In addition, these actions increase the likelihood that Muslim communities will fear the police, the FBI and other government institutions, and thus be less likely to cooperate with them. This enables “lone wolves” to remain undetected and offers fodder for Islamic State virtual recruiters trying to convince Muslims that the West is the enemy.

Overseas, Trump embraced the Saudi perspective of the Middle East. Saudi Arabia is an important counterterrorism partner, and relations with the Saudis became strained under Obama. Though Trump’s efforts to strengthen ties should be commended, the Saudi government continues to fund an array of preachers and institutions that promulgate an extreme version of Islam, enabling the Islamic State to recruit and otherwise gain support around the world. In addition, Saudi Arabia promotes an anti-Shia agenda that harms regional stability and fosters sectarianism, a key recruiting tool of the Islamic State.

Perhaps most troubling is how the president responded to the first significant jihadist attack on U.S. soil during his tenure—the October 2017 truck-ramming attack in New York City. At a time when a president should provide steady leadership, Trump (inevitably) began to tweet. He tried to turn the attack into a political issue, excoriating Sen. Chuck Schumer for the visa program that let the attacker into the country. He then stoked fears of immigration, called for the attacker to be sent to Guantánamo (and then apparently dropped that), and otherwise appeared erratic, partisan and lacking an understanding of the policy implications of his own words.

INSTEAD OF relaxing pressure as the Islamic State prepares to go underground, the United States must redouble its efforts. This will require crafting a sustainable coalition of local allies in Iraq and Syria that demands resources, skill and high-level engagement.

Training allied forces remains vital, but this must be understood as a limited solution rather than a cure-all. In theory, training allies seems a Goldilocks answer to many policy questions: it is relatively low in cost, it minimizes direct risk to U.S. forces and it helps reduce terrorism in the long term when newly capable allies can police their own territory. Yet, especially in the Middle East, these efforts often fail. Despite spending hundreds of millions on training programs in Iraq, Syria and elsewhere, U.S.-trained forces have often crumbled in the face of the adversary. Regime corruption, divided societies, politicized militaries and other problems plague the region, and U.S. training can only move the needle slightly. Limited progress is better than no progress, but other policies must supplement training programs.

To prevent the Islamic State from reestablishing itself in Iraq and Syria or spreading elsewhere in the region, the United States also must adopt a broader conception of counterterrorism, recognizing the link between jihadist terrorist groups and civil wars. Groups like the Islamic State exploit civil wars and worsen them: if civil wars in the Muslim world are left to rage, we can expect jihadist groups in the region to remain strong actors. Resolving civil wars is a strategic as well as a humanitarian imperative. Programs for conflict resolution and sustained U.S.-led diplomacy are vital to ameliorate the effects of civil wars.

Furthermore, the United States must also support allies on the front line, like Jordan, that are vulnerable to jihadist meddling. The United States must also strengthen nascent democracies that have a significant jihadist problem, like Tunisia. As such, the administration should rescind the proposed dramatic cuts to the already-small foreign-aid budget, and staff much of the Department of State, the civilian arm of the Department of Defense and other key agencies to strengthen the ability of the United States to use a whole-of-government approach to combating terrorism.

One significant problem is institutionalization. Since 9/11, the executive branch alone has executed counterterrorism policy, with some modifications by the courts. One branch of government, perhaps the most important in the long term, has been conspicuously absent under both parties’ leadership: the U.S. Congress. Under both Bush and Obama, new and controversial counterterrorism instruments—targeted killings, increased domestic surveillance, aggressive FBI sting operations, detention without trial and so on—moved to the center of U.S. counterterrorism efforts without significant congressional input. In addition, the United States is bombing the Islamic State in both Iraq and Syria with only dubious legal justification.

Defeating the Islamic State could be the marquee foreign-policy accomplishment of the Trump administration. Doing so, however, will require more than just forcing the caliphate underground. Instead, the administration must maintain pressure on the group in the Middle East, work with allies around the world and shore up efforts at home. Failing to do so will result in at best a respite, not lasting victory.

Daniel Byman is a professor and senior associate dean at Georgetown University’s Edmund A. Walsh School of Foreign Service and a senior fellow at the Brookings Institution’s Center for Middle East Policy.

Image: A view of Islamic State slogans painted along the walls of a tunnel near Mosul, Iraq, March 4, 2017. Reuters/Alaa Al-Marjani