Security officials in Britain are urgently preparing for the return of hundreds of UK nationals who went to fight for Islamic State, following an expected defeat of the group in Iraq and Syria.

The jihadi group’s strongholds in Mosul in Iraq and Raqqa in northern Syria, are expected to fall by the summer. An exodus of foreign fighters from the area is thought already to have occurred.

Security officials say they are particularly concerned by the prospect of very young children, including some who were born under isis rule in either Syria or Iraq, going to the UK with their parents.

One government source said: “It is possible they are going to return indoctrinated, deeply dangerous and damaged. The only analogous experience we have is handling children caught up in extreme religious sects. It is a huge challenge for family courts and social care.”

A militant website’s image, reported in 2015, of Isis fighters in Syria, heading to Iraq. Photograph: AP

In a drive to crack down on extremism infiltrating Britain, the government also wants to speed up the pace with which technology firms remove Isis-inspired propaganda from the internet. One source said the average timespan was 11 to 13 minutes, but pointed out that social media could be shared within seconds.

Counter-terror officers believe the criminal courts have the legal arsenal to handle the bulk of the 850 or so foreign fighters who went to Syria, so long as it can be proved in court they took part in fighting.

It is already a criminal offence to go to Syria or Iraq for the purpose of committing, or aiding, a terrorist act. But security officials are setting in train procedures to manage the return of foreign fighters, especially in cooperation with Turkey, a country many UK foreign fighters are likely to pass through.

The continued need to retain security cooperation with Turkey in part explains the British Foreign Office decision to minimise criticism of the authoritarian trend inside Turkey under the president, Recep Tayyip Erdoğan.

The EU security commissioner, Julian King, said this week that about a quarter of the 850 UK foreign fighters remained “in theatre,” adding: “Some will return with the intention of planning and executing future attacks.”

A broader effort is being made to handle the flow of all EU nationals around the continent. Non-EU citizens entering or leaving the bloc will be checked against a wider range of internationally connected databases, including the Schengen information system.

Burning oil facilities in Qayyarah, Iraq, hit in 2016 by an Iraqi or coalition airstrike for being an Isis base. Photograph: Zuma Wire/Rex/Shutterstock

Airports, including Charles de Gaulle in Paris, are said to be identifying very large numbers of suspects. Training is also under way to improve the quality of secondary interrogation of those picked up as potential suspects.

But EU officials admit the intelligence services, now operating at a central counter-terror group in the Hague, do not have the resources to retain eyes on all suspects.

The UK officers say that keeping tabs on the movements of many of the fighters will be a challenge, not just in the UK but in other countries such as Tunisia, Indonesia and Algeria, where the security apparatus is less sophisticated.

In total, 40,000 foreign fighters from more than 110 countries have gone to Syria and Iraq, the international development minister, Rory Stewart, confirmed this week. He warned that the speed with which these foreign fighters moved had caught the west offguard.

The rate at which UK foreign fighters seek to return is expected to depend on whether the fall of Mosul and Raqqa leads Isis fighters to move elsewhere along the Euphrates valley, particularly towards Al-Qa’im, a town in Iraq close to the Syrian border.

Security officials stressed that dispersed Isis members woulf continue to try to be active outside Europe, including in Turkey and Egypt.