Shamima Begum, who left the United Kingdom for Syria to join the Islamic State (IS) group as a teenager, will not be allowed to return and fight her citizenship case, the Supreme Court of the country ruled on Friday.
The court said in a unanimous ruling that her rights were not breached when she was refused permission to return.
Ms Begum, 21, wants to come back to challenge the home secretary's decision to remove her British nationality.
She is in a camp controlled by armed guards in northern Syria.
Ms Begum was 15 when she and two other east London schoolgirls left the UK in February 2015 and travelled to Syria to join the Islamic State group.
In 2019, the then-Home Secretary Sajid Javid stripped Ms Begum of her citizenship on national security grounds.
Last July, the Court of Appeal ruled that the only fair way forward was to allow her into the UK because she could not effectively appeal against the decision from the camp in northern Syria.
The Home Office subsequently appealed to the Supreme Court to reconsider the Court of Appeal's judgement, arguing that allowing her to return to the UK "would create significant national security risks".
On Friday, Lord Reed, president of the Supreme Court, said the government had been entitled to prevent Ms Begum from returning to the UK.
Announcing the ruling, Lord Reed said: "The Supreme Court unanimously allows all of the home secretary's appeals and dismisses Ms Begum's cross-appeal."
He said the Court of Appeal's judgment had been wrong and failed to take proper account of the home secretary's case.
"It did not give the home secretary's assessment the respect which it should have received, given that it is the home secretary who has been charged by Parliament with responsibility for making such assessments, and who is democratically accountable to Parliament for the discharge of that responsibility," Lord Reed said.
"The Court of Appeal mistakenly believed that, when an individual's right to have a fair hearing... came into conflict with the requirements of national security, her right to a fair hearing must prevail."
He added: "But the right to a fair hearing does not trump all other considerations, such as the safety of the public."
Lord Reed said the appropriate answer was not to force the government to bring Ms Begum back to the UK - but to pause her legal fight over citizenship until she is in a safer position to take part in her appeal.
He added: "That is not a perfect solution, as it is not known how long it may be before that is possible. But there is no perfect solution to a dilemma of the present kind."
Mr Javid welcomed the ruling, saying any "restrictions of rights and freedoms" faced by Ms Begum were a "direct" result of her "extreme" actions.
He said: "The home secretary is responsible for the security of our citizens and borders, and therefore should have the power to decide whether anyone posing a serious threat to that security can enter our country.
"There are no simple solutions to this situation but any restrictions of rights and freedoms faced by this individual are a direct consequence of the extreme actions that she and others have taken, in violation of government guidance and common morality."
Liberty, the human rights group which intervened in Ms Begum's case, said the latest ruling sets "an extremely dangerous precedent".
Rosie Brighouse, a lawyer with Liberty, said: "The right to a fair trial is not something democratic governments should take away on a whim, and nor is someone's British citizenship.
"If a government is allowed to wield extreme powers like banishment without the basic safeguards of a fair trial it sets an extremely dangerous precedent.
"The security services have safely managed the returns of hundreds of people from Syria but the government has chosen to target Shamima Begum.
"This approach does not serve justice, it's a cynical distraction from a failed counter-terror strategy and another example of this government's disregard for access to justice and the rule of law."
Maya Foa, director of the human rights group Reprieve said preventing Ms Begum from entering the UK remained "a cynical ploy to make her someone else's responsibility".
"Like many of its European counterparts, the UK is more than capable of bringing home British detainees in Syria, many of whom left as teenagers after being trafficked or groomed online.
"Abandoning them in a legal black hole - in Guantanamo-like conditions - is out of step with British values and the interests of justice and security."