Shamima Begum should be allowed to return to the UK to fight the decision to remove her British citizenship, the 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 judgement means the government must now find a way to allow the 20-year-old to appear in court in London despite repeatedly saying it would not assist removing her from Syria.
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
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'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 tribunal ruled that the decision to remove Ms Begum's citizenship was lawful because she was "a citizen of Bangladesh by descent" at the time.
She is understood to have a claim to Bangladeshi nationality through her mother.
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.