S UHEYLA REMEMBERS the day clearly. She had invited her children for dinner and was preparing her youngest son’s favourite stew. He never showed up. Neither did her four daughters. When none of them picked up the phone, she and her husband Lutfu understood what was happening. They rushed to a police station to ask the authorities to track down their children: they were headed south. A month later one of Suheyla’s daughters called. She and her siblings, the youngest 18 and the eldest 27, along with her brother’s wife and their infant son, had smuggled themselves into Syria and joined Islamic State ( IS ).

That was in late 2015. Today, three of the daughters are behind bars in Baghdad, having been captured by Iraqi forces two years ago. The fourth died in jail, two months after giving birth to a boy. Their brother, Yasin, has not been heard from in two years. Earlier this summer, Suheyla and Lutfu (not their real names) were united with two of their grandchildren, aged one and two, who were repatriated from Iraq. The toddlers were ill when they arrived. One was covered with sores, having caught scabies in the squalid prison in which he was born. He survived on his aunt’s milk.

At their apartment in Esenler, a conservative district in Istanbul, Suheyla fights back tears as she flicks through photos of her daughters on her phone. Like their parents, they were good, devout Muslims, she recalls, but they were not zealots. Their parents do not know how they were radicalised, but in a month they had transformed beyond recognition. Her daughters swapped their headscarves for shapeless black niqabs. Her son grew a beard. They began to praise the murderous caliphate that IS had founded in parts of Iraq and Syria. “You could not reason with them,” says Lutfu. “It was like a disease.”

Since the war in Syria began, at least 2,000 Turks are said to have joined the thousands of foreign jihadists who poured across Turkey’s southern border to fight alongside IS or al-Qaeda. Hundreds died on the battlefield. Some carried out suicide bombings at home. During a terrifying spell between 2015 and early 2017, at least 300 people died in a dozen IS attacks across Turkey. Most of the bombers were Turks. According to officials, about 500 home-grown IS supporters are in prison in Turkey, in addition to some 700 foreigners. Hundreds of Turkish women who joined the group, including Suheyla’s daughters, are held in Baghdad. Some fighters sneaked into Turkey as the caliphate began to collapse. Turkey must now come to grips with those militants, both domestic and foreign, who have returned from Iraq and Syria, and those planning to do so.

Belatedly, the country has begun to focus on prevention and rehabilitation. The government has organised seminars for Turkish and refugee children, to inoculate them against IS propaganda. The religious affairs directorate, which oversees the teaching of Islam, has trained 70 prison chaplains to work with religious extremists. The programme has enjoyed a measure of success. A pair of young sisters who pledged allegiance to IS , and then refused to be tried by a Turkish court, recanted after sessions with a female chaplain. They were released. Prison officials say they make a point of keeping IS supporters away from each other, and from other inmates. That is easier said than done. A massive and often indiscriminate crackdown following a violent coup attempt in 2016 has left the prisons more overcrowded than ever, leaving some 30,000 people behind bars. And some of those who came back from Syria were never picked up in the first place.

Turkey is getting some things right. Since the terror campaign of 2015-2017, the bombings have stopped. Officials credit improved co-ordination between agencies, as well as a sweeping purge of state institutions directed against members of the Gulen movement, an Islamic fraternity accused of spearheading the 2016 coup. Analysts say it took time for police and intelligence forces to infiltrate IS networks.

A wall constructed over stretches of the border and a military operation against IS strongholds in northern Syria have helped, making it harder for bombers to slip into Turkey. It is not for want of trying. Turkish police say they have foiled at least 28 large attacks since 2014, including a planned massacre at a shopping mall in Istanbul.

The threat the authorities now have to contend with is the exodus from Syria. Their caliphate smashed to pieces by Kurdish fighters and American air strikes, scores of IS fighters have escaped to Iraq. But the group also seems keen to expand its underground network in Turkey. “Three years ago, we were chasing terrorists who were about to blow themselves up,” says a counter-terrorism official. “Now we’re doing operations to disrupt their logistics and prevent IS financing from entering.”

Turkey once accused Western governments of neglecting to share intelligence about militants, making it hard to stop them at Turkish airports. Now it says they are trying to dump them on Turkey. According to officials, 775 suspected foreign fighters are being held at deportation centres, waiting to be sent home. Most have destroyed their old passports. Their consulates, however, are often slow to provide them with new travel documents, which delays or prevents deportation. Four have been stripped of citizenship, making repatriation impossible. Because they can only be held without charge for 12 months, they can expect to be set free. “If there’s no hard evidence against them, you cannot detain them or open a case,” says an official. “It’s a recipe for complete chaos.”