Wikileaks founder Julian Assange cannot be extradited to the United States, a court in London has ruled.
The judge blocked the request because of concerns over Mr Assange's mental health and risk of suicide in the US.
Mr Assange, who is wanted over the publication of thousands of classified documents in 2010 and 2011, says the case is politically motivated.
Expressing disappointment at the ruling, the US justice department noted that its legal arguments had prevailed.
Its position is that the leaks broke the law and endangered lives.
"While we are extremely disappointed in the court's ultimate decision, we are gratified that the United States prevailed on every point of law raised," the justice department said.
The US authorities have 14 days in which to lodge an appeal and are expected to do so.
Mr Assange will now be taken back to Belmarsh Prison - where he is being held - and a full application for his bail will be made on Wednesday.
His lawyer Ed Fitzgerald QC told the court there would be evidence to show Mr Assange would not abscond.
What did the judge say?
District Judge Vanessa Baraitser ruled that while US prosecutors had met the tests for Mr Assange to be extradited for trial, the US was incapable of preventing him from attempting to take his own life.
Outlining evidence of his self-harm and suicidal thoughts, she said: "The overall impression is of a depressed and sometimes despairing man fearful for his future."
She said: "Faced with the conditions of near total isolation without the protective factors which limited his risk at HMP Belmarsh, I am satisfied the procedures described by the US will not prevent Mr Assange from finding a way to commit suicide and for this reason I have decided extradition would be oppressive by reason of mental harm and I order his discharge."
Mr Assange, who wore a blue suit and green face mask in the dock, closed his eyes as the judge read out her ruling on Monday.
His fiancee Stella Moris, with whom he has two young sons, wept and was comforted by Wikileaks editor-in-chief Kristinn Hrafnsson, who sat next to her in court.
Speaking outside court after the ruling, she called on the US president to "end this now".
"Mr President, tear down these prison walls," she said. "Let our little boys have their father. Free Julian, free the press, free us all."
District Judge Vanessa Baraitser explicitly concluded that Mr Assange should answer allegations that he aided and abetted hacking, theft and the disclosure of the identities of informants working for the US security agencies - disclosures that endangered their lives.
In English law, that would be enough for him to be charged with a crime here - and so the route was open for Mr Assange to face trial for the same in the United States.
But British extradition law also requires a judge to consider Mr Assange's health.
And it's the effect of his possible detention in near-solitary confinement in a "supermax" prison that proved decisive.
The US, in the judge's conclusion, can't stop a mentally unwell man taking his own life in those conditions.
And so the legal requirement to treat Mr Assange humanely trumps the seriousness of the case that the judge acknowledges he should answer.
When the US appeals - it'll have to convince more senior judges otherwise.
What would Assange face in the US?
If convicted in the US, Mr Assange faces a possible penalty of up to 175 years in jail, his lawyers have said. However the US government said the sentence was more likely to be between four and six years.
Mr Assange faces an 18-count indictment from the US government, accusing him of conspiring to hack into US military databases to acquire sensitive secret information relating to the Afghanistan and Iraq wars, which was then published on the Wikileaks website.
He says the information exposed abuses by the US military.
But US prosecutors say the leaks of classified material endangered lives, and so the US sought his extradition from the UK.
Extradition is the process under which one country can ask another to hand over a suspect to face trial.
What reaction has there been?
Following the judgement, several politicians and organisations welcomed the news, although some expressed dismay that the ruling was made on health grounds:
- Mexican President Andres Manuel Lopez Obrador said he had instructed his foreign minister to offer political asylum to Mr Assange who "is a journalist and deserves a chance"
- "Good news Julian Assange's extradition has been blocked," said UK Conservative MP David Davis on Twitter. "Extradition treaties should not be used for political prosecutions"
- Former UK Labour leader Jeremy Corbyn called it "good news" but said it was "alarming that the judge has accepted US government arguments threatening freedom of speech and freedom to publish"
- Amnesty International welcomed the ruling but criticised the UK for "having engaged in this politically-motivated process at the behest of the USA and putting media freedom and freedom of expression on trial"
- The head of the National Union of Journalists, Michelle Stanistreet, said the outcome was "the right one" but the judgment contained "much that is troubling"
- Journalist and documentary maker John Pilger, who has been a vocal campaigner for Mr Assange, tweeted that it was "wonderful", adding the UK ruling was a "face-saving cover for the British to justify their disgraceful political trial of Assange on America's behalf"
Mr Assange was jailed for 50 weeks in May 2019 for breaching his bail conditions after going into hiding in the Ecuadorian embassy in London.
He sought refuge in the embassy for seven years from 2012 until he was arrested in April 2019.
At the time he fled to the embassy, he had been facing extradition to Sweden on allegations of sexual assault which he denied. That case was later dropped.