Erbil, Iraq—Inside a prison in the Kurdistan region of Iraq, vanquished Islamic State fighters who once swept through much of the country now mill about sullenly on a bare, tiled floor, reflecting on a cause they insist will endure. Many spend hours in fierce debate, apparently undeterred by their movement’s apparent military defeat. Their cause, they say, remains divinely ordained. Their capture incidental. “Hathi iradet Allah,” they say. This is God’s will.

A Kurdish guard called for a captive, whom I will call Abu Samya—a brooding Baghdad resident kidnapped first by the Islamic State’s forerunner group, al-Qaeda in Iraq, and later by Shia death squads as sectarian lines hardened in 2006–2007. As he walked toward the guard, some fellow captives condemned him as “kha’in,” or traitor. Outside the walls, long before the caliphate crumbled, that charge carried a death penalty. The jaded jihadist shrugged it off.

After a curt introduction, the thin man leaned across the table, eyeballing me. “There is no life left for me,” he said, in a tone of resignation that seemed briefly to disguise the unmistakable sense of anger years in the making. “Ask me anything.”

For the next two hours, Abu Samya laid bare his transformation from a laborer in a mixed, well-to-do suburb to an inmate in Camp Bucca, the US-run prison that came to define an era of the American occupation of Iraq. The journey took him from political disillusion to ideological commitment, and back again, shaping his values, then shattering them within a decade.

During our discussion, he reflected on a prewar era when sect or ethnicity barely mattered. “We lived in peace,” he said. He pulled back a sleeve to reveal a scar that he claimed was caused by an electric drill used in torture by Shia militiamen after sectarian tensions exploded during the civil war unleashed by the US invasion. That scar has since been both a constant reminder and a visceral incentive for revenge.

“I started to hate them and the government,” he said.

Abu Samya proceeded to tell me his story in unabashedly sectarian terms. Though just one man’s account, it could easily have been a collective statement about a society blighted by fifteen years of war and deprivation, often on a family-by-family basis. His sense of disenfranchisement led him to the Islamic State, or ISIS, the terrorist group whose claim to address the grievances of Iraq’s Sunnis acted as a rallying call for many who were not attracted purely by ideology.

Now, more than four years after the black-clad men conquered Mosul, a major city in northern Iraq, a third of the country remains pulverized, both physically and socially. Overlaid across territory that has been reclaimed from the Islamic State is a patchwork of various sectarian militias that now claim fiefdom. Thousands of families with alleged links to ISIS are exiled, their birthrights reduced to being names on militias’ wanted lists, their dignity violated in irreversible ways. Rather than address this deep residue of fears and feelings of injustice felt by many, Iraq has foolishly declared the Islamic State defeated, as though its threat were now confined to the country’s past. But the signs of the ISIS’ resurgence are troubling, and the sense of grievance that fired it in the first place remains just as palpable—and just as unresolved.

The intelligence that my colleagues and I in the Kurdistan Region Security Council have collected is disturbing. Over the past fifteen months, hundreds of attacks linked to the group took place in areas that were supposed to have been freed from ISIS. Pushed out of Mosul, Islamic State fighters have regrouped in the provinces of Kirkuk, Diyala, Salahaddin, and parts of Anbar—territory they know well. From the city of Hawija to the westernmost town of Tal Afar, these guerrillas are mounting ambushes against Iraqi security forces in attacks the scale of which has not been seen in years.

What makes these fighters so much more of a threat now is their ability to make good on their promise to hunt down those they accuse of betraying them. In a night raid last October, after security forces had retreated to nearby bases, Islamic State assassins dragged a village chief from his home, and summoned locals to a public place, where they executed him. Even in parts of Mosul itself, reconquered in 2017 by government forces after a long and costly campaign, the ominous black-and-white ISIS flag has flown again in recent months, causing panic and fear in village after village. Credible threats have also forced the Iraqi authorities to relocate prisoners to prevent their escape in the event of a brazen attack like the prison breakouts the group has pulled off in the past.

The reasons for the return of ISIS are obvious. For years, the conventional approach to stopping the group has depended on airstrikes and local proxy forces; stripping away territory and revenues from ISIS has been the marker of success. But this is a gross misunderstanding of the group. The original synergy between former Iraqi officers and jihadists that created al-Qaeda in Iraq led to a calculating organization capable of learning from its mistakes and adjusting accordingly. To the group’s ex-military echelons, men whose expertise was repeatedly tested during the Iran–Iraq War in the 1980s and sharpened during the Sunni insurgency of the early 2000s, holding territory was understood as a temporary, tactical objective. Instead, thousands were trained to blend in, emerging only when they needed to.

Today, the group has evolved further. It has adapted to the antipathy found among the millions forced to flee their homes or chafing under the yoke of Shia militia rule, certain of the Islamic State’s inevitable return. Mosul, for instance, is exactly where ISIS wants it to be, filled with popular resentment that will gradually push locals back into the group’s orbit without its active intervention. ISIS has instead put its resources into a campaign at the village level, in rural areas where security is nonexistent at night—and that has paid off. Through 2018, dozens of village chiefs have been killed across northern Iraq in assassinations, bombings, and kidnappings. At least thirteen have been killed since December, including four in Mosul. The assassins travel in small groups under the cover of darkness and know exactly which houses to target. They enter villages with names in hand, sometimes dressed in military uniform; the lucky ones are the locals who get a warning to cut their links with the government.

In the rugged Hamrin mountain ranges that straddle several provinces—territory even US forces once struggled to control—new recruits now undergo training in fieldcraft. Around Kirkuk and in Hawija, some 700 fighters have regrouped to abduct Kurds and Arabs for ransom and target power lines and oil trucks, as well as police units defending critical infrastructure. Dozens of fighters have also trickled back into Badush heights, Zummar, and Rabia to the northwest of Mosul to resume guerrilla warfare from their former redoubts. In recent months, scores of houses belonging to military and militia officers and locals who connect villages to state authorities have been burned or reduced to rubble. Improvised bomb attacks, the militants’ signature tactic, are also back as a daily feature across the north of the country, with hundreds recorded last year. And as the militants increase their bomb-making capacity, major roads littered with explosive devices have already become “no go” zones for many international organizations.

The American-led military effort to reconquer the last patch of land held by ISIS in Syria last summer forced a reckoning among the Iraqis in the group’s ranks. With the demise of the caliphate, these returning fighters now plan to reclaim Mosul and Salahaddin, and are adept at infiltrating the porous border. This is part of a clear blueprint to reestablish the northern supply routes used during the original insurgency era to smuggle fighters, weapons, and chaos into the rest of Iraq.

Kurdistan Region Security Council intelligence also reveals that Iraqi government forces have returned to some of the practices that originally fed the ingrained sense of local grievances. In recent months, we have seen a surge in arrests using an anti-terrorism law widely perceived as unfairly targeting Sunnis. At checkpoints, and inside their homes, Sunni dignity is being violated in ways that provoke bitter resentment. In dawn raids by Iraqi security forces, soldiers slip hoods over the heads of detained civilians and bind their wrists tightly with plastic cuffs, treating them as presumed guilty. At sprawling prison camps, new arrivals find common ground with thousands picked up under this law since 2014, many detained indefinitely without trial and increasingly without hope of living to see any evidence laid against them. Back in the Sunni villages, ISIS exploits the new fertile ground to creep in at night, replenishing supplies and planting bombs by roadsides and checkpoints, with the tacit approval of resentful locals.

And it is not just the state security forces that are the cause of local alienation. Sectarian militias operating independently of Iraq’s weak government again loom large. Round-ups by militias following ISIS ambushes are commonplace: a practice that is not just a legacy of the American war in Iraq, but that is certainly a reminder of the daily humiliation that comes with foreign occupation—a central theme of the ISIS narrative. One of my associates who has researched the connection between the anti-terrorism law and radicalization told me that her international NGO, too, is alarmed about the uptick in arrests. There have been credible reports of war crimes: in one case in western Mosul last year, dozens of young men, including children and teenagers, accused of being informants were forced to kneel and then shot in the head by militiamen. When the guns finally fell silent, volunteers raced to dump the bodies; families who dared speak out risked exile or worse.

The anti-terrorism law has long been viewed as an affront to Sunni dignity. In 2012–2013, mass protests across northern and central Iraq demanded that the authorities in Baghdad scrap the law. Widely seen as a discriminatory tool, the law permits security forces to act on unsubstantiated evidence and fails to distinguish between those who actively sympathize with militants and those who fall prey to coerced cooperation. In 2013, even the Shia spiritual leader the Grand Ayatollah Ali Sistani expressed support for the Sunnis’ “legitimate” grievances against the anti-terrorism law.

With the government falling short of its responsibilities to Iraq’s millions of returning displaced people, and unwilling or unable to rein in Shia militia rule, ISIS is winning the war for hearts and minds. Amid the general economic misery, reconstruction efforts have been held up in areas seen as having supported ISIS. Over the last year, some 32,000 internally displaced people have left camps and gone back to their homes elsewhere in Iraq, but a similar number of newly displaced people and refugees have joined the multitudes already living in flimsy tents in the Kurdistan region. Baghdad has allocated to Mosul, home to a full tenth of the country’s population, just 1 percent of the federal budget reserved for provinces. Even clearing the untold number of unexploded bombs and abandoned munitions will be a generational struggle. An international expert who leads part of that effort told me that with the limited resources, it will take a full five years to clear the province.

Stopping the return of ISIS demands an understanding of how the group has embedded itself in Iraqi society over the past fifteen years of conflict. It matters less to occupy the country’s northern provinces with enough government forces than it does to remove the causes of the unending grievances that enable the group to flourish. And while a military component will always be important in providing security to the region, the struggle remains a political question confined to a stretch of territory decimated by war and broken in spirit, and to a community that ISIS has persuaded to give up the political process and turn to rebellion.

Iraq’s international partners waste diplomatic capital hoping to disband the sectarian militias that have emerged since 2003. This is wishful thinking; the militias are a permanent feature that will only become more entrenched over time and conflict, capitalizing on election cycles to transform foot soldiers into government officials to exploit the country’s resources. The priority instead must be to end the abusive practices that are fueling ISIS’ growth. International aid should go to security and intelligence services that are bearing the brunt of ISIS’ low-level insurgency. Rather than use the harsh measures of the anti-terrorism law, local police units with Western observers and training can start to build the grassroots support and reliable intelligence collection essential for disrupting ISIS’ subversion.

On the national level, the newly-appointed government should give arrest-and-detention powers exclusively to local police units. By removing the army, counter–terrorism units, and sectarian militias from populous urban areas, the government can shift a greater military presence to the ungoverned rural districts where ISIS dominates. And it is not enough to patrol in those areas only during the day; Iraqi forces must control territory at night to guarantee safety to locals who have dared to turn their guns on the militants.

But Baghdad could do more. It could consider an amnesty, or at least reduced sentences, for prisoners on a case-by-case basis; suspend the death penalty; and make generous cash handouts in areas that were battered by a savage US-led air campaign. Compensation applications take years for the dysfunctional legal system to process; depending on a claimant’s past ties to the caliphate, navigating through the system involves bribes and multiple visits to intelligence services. Today, more than fifteen months since Mosul was liberated, not a single claim by ISIS victims—whether Arabs, Kurds, Christians, or Yezidis—has been settled. Religious leaders complain bitterly about the absence of a clear process for locals to file claims.

Second, given that security checks have already been done for the displaced community in the Kurdistan region, a new intelligence-sharing arrangement with Baghdad could slash waiting times and return dignity to thousands of families whose honor may be mistakenly stained by perceived links to ISIS. And lastly, changes are needed at the provincial level. Raids based on informants’ tips—sometimes from individuals nursing grudges—should be subject to local approval. That would give Baghdad officials some purchase in the Sunni political landscape, as well as allow their provincial representatives a chance to persuade those who are disillusioned to split from the jihadist ideologues. Backed with better funding, governors could also direct mine-clearing operations to neighborhoods to which displaced people are returning, and follow up with basic service provision and expanded reconstruction efforts.

In the long term, progress depends on the Iraqi government making good on the commitment to decentralize power; locals better understand their immediate needs than Baghdad does. And that seems to work even among those provoked by sectarianism.

Back in the Kurdish prison, Abu Samya hinted to me that there remained room for progress. As with most prisoners, the turning point for him came in 2006, when ethnic violence triggered population swaps. He claims to have tried, in vain, to navigate alternate threats from both Sunni and Shia armed groups; he even resorted, he says, to trying to pass as a Christian. Then, one morning, a threat to leave the neighborhood came in the form of a note tucked under his front gate.

I asked him if it was too late to undo the animosity among the country’s traumatized ethnic communities. At first, he struck a defiant tone: “Every night I thought about this question. I thought about what to do as revenge.” Then, he let out a sigh, almost resisting the urge to speak. “My future is lost,” he said, his palms facing up, frozen in mid–air for a brief moment. But for other Sunnis outside the prison, it is not. “We just want to live peacefully. Let us govern our affairs.”