No matter where you turn when covering ISIL’s two years of terror in Iraq and Syria, one name repeatedly crops up: Tal Afar.

The town, with an estimated 200,000 residents when ISIL (a.k.a. the Islamic State), captured it two years ago, is perched on the dusty plains of northern Iraq, just shy of the Syrian border. Its native sons are thought to have taken a lead role in massacring Yazidis in nearby Sinjar during the summer of 2014. When ISIL seized the Mosul Dam for 12 days that August, a water engineer who’d previously managed Tal Afar’s drainage system was put in charge of it.

Reuters, modified by Quartz

Even now, with ISIL on the back foot, Afaris have cultivated a reputation as fierce guardians of the caliphate’s shrinking territory. Last month an American airstrike reportedly killed Abd al-Rahman Mustafa al-Qaduli, a deputy to the self-declared “caliph” of ISIL, who had spent much of his career in Tal Afar. It is thought to have provided at least half a dozen ISIL commanders and hundreds of foot soldiers.

How did an otherwise undistinguished town, previously best known for its opposition to the colonial British, become a notorious jihadi breeding ground? The answer to that is central to understanding ISIL’s rise and its appeal. It’s also a recipe for identifying future potential hotbeds of extremism.

Take one sectarian split

The first ingredient for Tal Afar’s radicalization was its sectarian mix. Ethnically, Afaris are Turkmen, Iraq’s largest group after Arabs and Kurds. Religiously, though, they are split: about one quarter to one third Shia, and the remainder Sunni.

“They had been living under the umbrella of ethnic Turkmen culture … But once these identity politics came in, there were problems.”

That mix is unusual in Iraq’s predominantly Sunni north. And it became explosive after Saddam Hussein’s overthrow in 2003, when Iraqi politics took on a nakedly sectarian bent as Saudi Arabia and Iran grappled for influence. “They had been living under the umbrella of ethnic Turkmen culture. They have the same language, the same food,” says Faleh Jabar, Director of the Iraq Institute for Strategic Studies and an expert on tribalism. “But once these identity politics came in, there were problems.”

The government of prime minister Nouri Al-Maliki, which ruled from 2006-2014, adopted a plainly pro-Shia agenda, even redirecting food from the north. Tensions spilled out into the open. The Shia Turkmen of Tal Afar got military training from Shia militias. Sunni Turkmen wanted the same thing, and Sunni jihadists—the precursors of ISIL—were only too happy to provide it. “I think jealousy drove many to join on an individual basis,” Jabar suggests.

Things really came to a head, he says, in 2013, when 300 Sunnis died in clashes with the Iraqi Army in Hawija, a town some three hours drive away. “The heavy-handed policies towards Hawija, which has many family connections to Tal Afar, strengthened the collective Sunni identity in the north,” Jabar says.

Reuters/Stringer A Shia Turkmen family that fled the fighting in Tal Afar in 2014.

Add a history of smuggling

As far back as 2004, al-Qaeda leader Abu Musab Al-Zarqawi took advantage of Tal Afar’s proximity to the Syrian border, using it as a staging point to funnel foreign fighters into Iraq. But well before then, Afaris had been making a living from cross-border smuggling.

After the US imposed sanctions on Iraq for Saddam’s weapons programs in the 1990s, stifling many regular trade routes, business in Tal Afar boomed. Well-organized criminal networks sprang up to facilitate the trade. “They were the smuggling kings. Drugs, guns, food, tractors, you name it. They took it,” said Mamdouh Mohammed, a farmer in Rabia, which sits right on the border, 50km (30 miles) away.

Stir in decades of ethnic discrimination and a few years of drought

Even after sanctions ended, residents of Tal Afar continued to deal contraband and ferry cheaper Syrian domestic goods. Several bad years of drought since 2005 had turned the area into a dustbowl, unsuitable for serious farming. Afaris often lacked proper education and were deprived of government jobs by Arab bureaucrats who looked down on them as Turkmen. Crime was seemingly one of the few money-spinning opportunities on offer.

Mix in a dollop of urban-rural divide

Like al-Qaeda before it, ISIL has enjoyed success in exploiting Iraq’s stark urban-rural divide.

“The appeal of groups like al-Qaeda, like [ISIL], is that they kind of offer the destruction of the social hierarchy.”

One reason is economic. ISIL captured oilfields as a source of revenue. Until the US started bombing those oilfields in earnest late last year, the jihadis were able to promise many poor villagers salaries beyond their wildest dreams.

But experts say what attracts people to ISIL is more than mere riches. Many villagers and townspeople in the Nineveh governorate, in which Tal Afar sits, nurse a deep resentment at what they see as the condescending attitude of urban elites in Mosul, Nineveh’s provincial capital.

“The [people from the countryside] were seen as peasants, and the appeal of groups like al-Qaeda, like [ISIL], is that they kind of offer the destruction of the social hierarchy. They seemingly give other people the chance to be on top,” said Rasha Al-Aqeedi, a native of Mosul and researcher at the al-Mesbar Studies and Research Center in Dubai. “With the Afaris in particular, this was their opportunity to be accepted. They’d always had problems with everyone, and now they had this sense of power.”

“It’s like when a kid who gets bullied at school in America goes home, and then comes back with a gun.”

It’s no coincidence, Faleh Jabar feels, that ISIL first made inroads into Nineveh by winning over the disgruntled sheikhs of the villages that ring Mosul. Nor is it surprisingly, Aqeedi thinks, that the city’s hisba—its religious police, who are known for their brutality—are mostly drawn from the surrounding rural hinterland.

“It’s like when a kid who gets bullied at school in America goes home, and then comes back with a gun and shoots everyone,” she said. “It’s because they were being mean.”

Then wait until it subsides

ISIL still controls Tal Afar, and some of the group’s leaders have supposedly even dispatched their families there for safekeeping ahead of an anticipated assault on Mosul. But as the US-backed coalition winnows away at the terrorists’ holdings, Tal Afar too has come under attack from the air and ground. ISIL’s chemical weapons chief was seized from near the town by US special forces in February, while successive “emirs” (commanders) of Tal Afar have been killed in airstrikes.

“They’re beyond redemption. God doesn’t want them.”

Given Afaris’ fighting prowess, there’s reason to believe they’ll be among the last jihadists to submit in northern Iraq. If nothing else, the renowned Chechen fighters barracked in and around the citadel seem unlikely to go down without a vicious fight.

So what ought to become of Tal Afar when it is finally captured? Its residents were scarcely tolerated before; now they’re widely reviled. Some rival tribesmen in neighboring Rabia favor razing Tal Afar to the ground.

“They’re beyond redemption. God doesn’t want them,” said Mamdouh Mohammed, the farmer in Rabia, whose Shammar tribe has suffered countless atrocities after refusing to pledge allegiance to ISIL.

“They’re jihadi scumbags, they’ve always been jihadi scumbags, and they always will be jihadi scumbags,” insisted Jemil Mohammed, a colonel in the Kurdish Peshmerga, whose paramilitary police unit has been active in clearing villages around Tal Afar.

But even if wiping out the town were morally acceptable, Tal Afar is simply too big to stifle and too problematic to ignore. “It’s a huge population. You can’t put them all on trial,” said Rasha Al-Aqeedi. “Who knows what can be done?”