Shamima Begum should be allowed to return to the UK to fight the decision to remove her British citizenship, the UK Court of Appeal has ruled.
Ms Begum, now 20, was one of three schoolgirls who left London to join the Islamic State group in Syria in 2015.
Her citizenship was revoked by the Home Office on security grounds after she was found in a refugee camp in 2019.
The Court of Appeal said she had been denied a fair hearing because she could not make her case from the Syrian camp.
The Home Office said the decision was "very disappointing" and it would "apply for permission to appeal".
The ruling means the government must now find a way to allow the 20-year-old, who is currently in Camp Roj in northern Syria, to appear in court in London despite repeatedly saying it would not assist removing her from Syria.
Lord Justice Flaux - sitting with Lady Justice King and Lord Justice Singh - said: "Fairness and justice must, on the facts of this case, outweigh the national security concerns, so that the leave to enter appeals should be allowed."
The judge also said that the national security concerns about her "could be addressed and managed if she returns to the United Kingdom".
Daniel Furner, Ms Begum's solicitor, said: "Ms Begum has never had a fair opportunity to give her side of the story.
"She is not afraid of facing British justice, she welcomes it. But the stripping of her citizenship without a chance to clear her name is not justice, it is the opposite."
Government 'shirked' responsibilities
Ms Begum's legal team was challenging the government's decision to revoke her citizenship on three grounds - that it was unlawful because it left her stateless; it exposed her to a real risk of death or inhuman and degrading treatment; and she could not effectively challenge the decision while she was barred from returning to the UK.
Under international law, it is only legal to revoke someone's citizenship if an individual is entitled to citizenship of another country.
In February, a specialist tribunal - the Special Immigration Appeals Commission (SIAC) - ruled that the decision to remove Ms Begum's citizenship was lawful because she was "a citizen of Bangladesh by descent".
She is understood to have a claim to Bangladeshi nationality through her mother.
SIAC, a semi-secret court which hears national security cases, also said that although there were concerns about how Ms Begum could take part in the proceedings in London, those difficulties did not mean the home secretary's decision should be overturned.
In his ruling on Thursday, Lord Justice Flaux said: "It is difficult to conceive of any case where a court or tribunal has said we cannot hold a fair trial, but we are going to go on anyway."
Human rights organisation Liberty, which intervened in Ms Begum's appeal, welcomed the ruling, saying the right to a fair trial was "a fundamental part of our justice system and equal access to justice must apply to everyone".
Liberty lawyer Katie Lines added: "Banishing someone is the act of a government shirking its responsibilities and it is critical that cruel and irresponsible government decisions can be properly challenged and overturned."
Ms Begum left Bethnal Green, in east London, aged 15 for Syria in February 2015, with two school friends.
Within days she had crossed the Turkish border and eventually reached the IS headquarters at Raqqa, where she married a Dutch convert recruit. They had three children - all of whom have since died.
Source: BBC