LAST month a court in the Netherlands convicted a 22-year-old Dutch woman of helping to plan terrorism. It then set her free. Laura H. (her last name is protected under Dutch law), a Muslim convert, had moved to territory controlled by Islamic State (IS) with her Palestinian-Dutch husband in 2015, hoping to find a theocratic paradise. Quickly disillusioned, she spent a year planning her escape with the help of her father back home. The plan went wrong. As recounted by Thomas Rueb, a Dutch journalist, Laura and her children were nearly killed in a firefight before stumbling into the hands of Kurdish soldiers. The court ruled that by moving to IS-held territory with her husband she had aided terrorism, but found her 11 months of pre-trial detention to be enough.

Laura is one of about 5,000 residents of the European Union who have gone to Iraq and Syria since 2014 as jihadist fighters or supporters. Over the past six months, as IS has collapsed, Europe has braced for the prospect of more jihadists coming home, bringing their combat training (and combat trauma) with them. Whereas some may be disillusioned with radicalism, others are likely to engage in terrorism. Returned jihadists have already taken part in attacks in Belgium and France. Security services face the task of tracking them as they re-enter Europe. Courts must decide whether to lock them up. Social services must figure out how to reintegrate them into society.

France faces the biggest challenge. Its interior ministry says 1,700 French have joined the fighting. Emmanuel Macron, the president, has promised that returning fighters will be tried, while women and children will be treated on a “case-by-case” basis. So far the challenge seems manageable: only 302 had returned by November, and there has been no noticeable surge.

But that could soon change. In the chaos of IS’s collapse, most of its European jihadists are unaccounted for. “Until a year ago we had good estimates of who was fighting where. Now that overview is lost,” says Edwin Bakker of the International Centre for Counter-Terrorism in The Hague. Many will have been killed. However, the BBC reports that hundreds of IS fighters, including some Europeans, escaped the fall of Raqqa. Pieter van Ostaeyen, a Belgian academic who tracks jihadists, says some may be heading for conflict zones in north Africa; others may target Europe. “Wherever they find an opportunity to wage IS’s war, that’s where they will go,” he says.

Vilvoorde, a Belgian town just north of Brussels, is trying to make sure it is not one of those places. In the two years before IS declared its state, 28 people left the town of 40,000 to join jihadist groups in Syria, believed at the time to be the highest share in western Europe. But after 2015 no more joined them. The town chalks its success up to an intensive programme of engagement with communities and families to identify youth at risk of radicalisation.

Hans Bonte, Vilvoorde’s mayor, says his government’s close links with the Muslim community help it prevent returned jihadists from engaging in crime. Of the 28 who left, eight have come back; six of these are in prison, one has died, and one has been released and is reintegrating peacefully.

But even Vilvoorde suffers from Europe’s biggest counter-terrorism weakness: poor communication between security agencies at home and abroad. The imam who allegedly masterminded the attacks that killed 13 people in Barcelona in August, Abdelbaki Es Satty, stayed in Vilvoorde in 2016 and tried to find work at a mosque there. Mr Bonte says members of the mosque alerted his government and Vilvoorde police contacted Spanish authorities, who failed to inform them that Mr Es Satty was suspected of terrorist links.

Co-operation against terrorism is getting better. Europe-wide arrest warrants and an improved information system make it easier to pick up returning jihadists as they re-enter Europe. But some of the problems revealed after the attacks in Paris and Brussels in 2015 and 2016 have yet to be resolved. “Brussels is chaos,” says Mr Bonte. The city is divided among 19 municipalities and six separate police forces, which find it hard to co-ordinate their counter-terrorism efforts.

Then there is the problem of how to treat the returned jihadists. Some in the Netherlands criticised the leniency of Laura H.’s sentence. But punishing relatively innocuous returnees harshly has the downside of alienating other Muslims, and can damage anti-terrorism co-operation. Penning returning jihadists together in jail for years may only exacerbate the problem. As André Seebregts, a Dutch lawyer who represents jihadists, puts it: “I don’t think I know any who have become less radical in prison.”