With the Islamic State terror organization's so-called caliphate on the brink of total collapse as Kurdish-led militias flush the last die-hard fighters from the tiny pocket of territory still under their control in eastern Syria, European Union nations face an unprecedented dilemma: what to do with captured IS members in possession of EU passports.

The EU was yet to draw up a common policy on this matter but member states were weighing up two main options, either repatriate their citizens and bring them to justice or strip them of their nationality and leave their fate to their captors.

Carola García-Calvo, a lead investigator at the Global Terror Program at the Royal Elcano Institute in Spain, said another option would be to create "an ad hoc international criminal court to deal with the phenomenon."

The option to withdraw a suspected IS member's citizenship became the subject of heated debate when the United Kingdom's Home Office announced it would revoke the nationality of Shahima Begum, a 19-year-old Londoner who traveled to Syria to join the extremist group with two friends in 2015 when she was just 15.

Her case, which has grabbed headlines in British newspapers in recent days, has divided politicians and commentators.

Shahima Begum's family said they would challenge the decision of Home Secretary Sajid Javid to revoke her citizenship.

"We wish to make clear, that along with the rest of the country, we are shocked and appalled at the vile comments she has made to the media in recent days," the letter, written by Shahima's sister Renu, said.

In a recent interview, Shahima, who was living in a refugee camp in Syria, said she was shocked by the 2017 Manchester Arena attack – when an assailant detonated a suicide bomb at an Ariana Grande concert, killing 23, including the attacker – but compared it to Western airstrikes in Iraq and Syria.

The letter said, however, that British authorities could not "simply abandon her" and that her nationality status should be decided by the UK judiciary.

Over 1,300 foreign IS fighters have been detained by the Syrian Democratic Forces, a United States-backed umbrella militia led by the Kurdish People's Protection Units (YPG), which was currently routing the IS out from its last-stand territory, a small town called Baghouz on the banks of the Euphrates near the Iraqi border in eastern Syria.

The YPG has called on members of the international community to repatriate foreign IS members to take the alleviate burden of imprisonment.

The SDF has been one of the most effective ground forces against the IS in the Syrian war.

The United States president, Donald Trump, said around 800 EU nationals are among the captured IS members. He, too, has urged corresponding nations to repatriate them and warned that failure to do so could see the extremists released.

"I think the issue here is the numbers, they are much higher than previously thought in Europe," García-Calvo said. "The debate in the EU has been going on for some time but there is still no common position, it hasn't been reached," she added.

According to a study published last July by the Centre for the Study of Radicalisation at King's College London, at least 41,490 foreign fighters joined IS ranks in Iraq and Syria. At least 7,366 of them have since returned to their country of origin.

The report estimated that 5,904 foreign IS fighters came from Western Europe, of which 1,765 have returned home.

France was the leading exporter of the IS fighters, with an estimated 1,910 French nationals traveling to warzones to join the extremist group. Germany and the UK followed with 960 and 850 respectively.

García-Calvo said around 240 Spanish nationals had joined IS.

"In terms of the number of those who have returned, we're talking about an estimated 50," she added.

According to the Spanish defense ministry, there were no known extremists with ties to Spain in the camps of Iraq and Syria.

Liam Duffy, a British counter-terror expert with the strategic institute Civitas, said he could understand the UK's decision to revoke Begum's nationality given that authorities feared she could present a security risk.

However, he said he personally believed it was not the correct decision given that people like Begum present a greater security threat to the fragile states where they are held captive, in this case, Iraq and Syria.

If other countries followed the UK's example, there would be a large group of nationless extremists, which, in his opinion, could present a global security threat in the long run.

He said captured IS members should be brought before the courts on a case by case basis, given the complexity of the situation.

IS leader Abu Bakr al-Baghdadi, whose whereabouts remained unknown to authorities, declared the so-called caliphate during a speech at the Great Mosque of al-Nuri in the Iraqi city of Mosul on July 4, 2014.

At the height of its power, the caliphate stretched across great swathes of Iraq and Syria, from the historic city of Mosul to Raqqa, Der Ezzor and Palmyra in Syria.

It became a well-organized and brutal proto-state adherent to fundamentalist interpretations of Islam.

The group gained widespread media attention in the West with its slick propaganda videos of executions, including the beheading of US journalist James Foley in 2014 and for its terror attacks in Europe, such as the 2015 Paris attacks that claimed the lives of 130 victims.

The IS also carried out campaigns of ethnic cleansing and sexual enslavement of the Yazidi religious minority around Mount Sinjar in northern Iraq.

It was now on the brink of collapse territorially.

Hundreds of civilians, IS fighters and families have been evacuated from Baghouz in recent days. Many were being held in nearby camps while the international community ponders its next move.

By Isaac J. Martín