British computer hacker Gary McKinnon will not be extradited to the US, Home Secretary Theresa May has announced.
Mr McKinnon, 46, who admits accessing US government computers but claims he was looking for evidence of UFOs, has been fighting extradition since 2002.
The home secretary told MPs there was no doubt Mr McKinnon was "seriously ill" and the extradition warrant against him should be withdrawn.
Mrs May said the sole issue she had to consider was his human rights.
She said it was now for the Director of Public Prosecutions, Keir Starmer QC, to decide whether he should face trial in the UK.
Mrs May said: "Since I came into office, the sole issue on which I have been required to make a decision is whether Mr McKinnon's extradition to the United States would breach his human rights.
"Mr McKinnon is accused of serious crimes. But there is also no doubt that he is seriously ill.
"He has Asperger's syndrome, and suffers from depressive illness. The legal question before me is now whether the extent of that illness is sufficient to preclude extradition.
"After careful consideration of all of the relevant material, I have concluded that Mr McKinnon's extradition would give rise to such a high risk of him ending his life that a decision to extradite would be incompatible with Mr McKinnon's human rights."
Mrs May also said measures would be taken to enable a UK court to decide whether a person should stand trial in the UK or abroad - a so-called forum bar.
It would be designed to ensure extradition cases did not fall foul of "delays and satellite litigation", she said.
"I believe extradition decisions must not only be fair, they must be seen to be fair. And they must be made in open court where decisions can be challenged and explained," she said.
"That is why I have decided to introduce a forum bar. This will mean that where prosecution is possible in both the UK and in another state, the British courts will be able to bar prosecution overseas if they believe it is in the interests of justice to do so."
Mr McKinnon, from Wood Green, north London, who has been diagnosed with Asperger's syndrome, a form of autism, faced 60 years in jail if convicted in the US.
Mr McKinnon's mother Janis Sharp was delighted with the decision, saying: "Thank you Theresa May from the bottom of my heart - I always knew you had the strength and courage to do the right thing."
His MP, David Burrowes, who had threatened to resign as a parliamentary aide if Mr McKinnon was extradited, welcomed the decision.
Mr Burrowes, Conservative MP for Enfield Southgate in north London, tweeted: "Compassion and pre-election promises delivered today."
BBC legal correspondent Clive Coleman said it was a dramatic decision - the first time a home secretary had stepped in to block an extradition under the current treaty with the US.
Shami Chakrabarti, director of civil rights group Liberty, said: "This is a great day for rights, freedoms and justice in the United Kingdom.
"The home secretary has spared this vulnerable man the cruelty of being sent to the US and accepted Liberty's long-standing argument for change to our rotten extradition laws."
Mark Lever, chief executive of the National Autistic Society, said he was "delighted that the years of waiting are finally over for Gary and his family".
But Labour former home secretary Alan Johnson criticised the decision and claimed Mrs May had made a decision which was "in her own party's best interests but it's not in the best interests of this country".
He said: "Gary McKinnon is accused of very serious offences. The US was perfectly within its rights and it was extremely reasonable of them to seek his extradition."
Shadow home secretary Yvette Cooper asked Mrs May about the implications of her decision: "Clearly other people subject to extradition proceedings or immigration proceedings do cite medical conditions as a reason not to extradite so it would be useful for Parliament and the courts to understand the tests you have applied and whether that will set precedent in other cases."
American lawyer, David Rivkin, a former White House adviser, said the decision was "laughable", adding, "Under that logic, anybody who claims some kind of physical or mental problem can commit crimes with impunity and get away with it."
US extradition expert Douglas McNabb said the US Attorney's Office would be furious and he suspected it would ask Interpol to issue a red notice - making other nations aware there was an outstanding arrest warrant for Mr McKinnon in the US - which would mean he could be arrested if he left the UK.
The family of terror suspect Babar Ahmad said while they welcomed the decision not to extradite Mr McKinnon, questions had to be asked.
Mr Ahmad was one of five terror suspects, including radical cleric Abu Hamza al-Masri, extradited to the US earlier this month. His co-accused, Talha Ahsan, who was also extradited, was diagnosed with Asperger's in June 2009, according to a European Court of Human Rights judgement.
Both are accused by US authorities of running a pro-jihad website.
Mr Ahmad's family said: "Why within the space of two weeks, a British citizen with Asperger's accused of computer-related activity is not extradited, while two other British citizens, one with Asperger's, engaged in computer-related activity are extradited. A clear demonstration of double standards."
US authorities have described Glasgow-born Mr McKinnon's actions as the "biggest military computer hack of all time" and have demanded he face justice in America.
They insisted his hacking was "intentional and calculated to influence and affect the US government by intimidation and coercion".
The Americans said his actions caused $800,000 (£487,000) worth of damage to military computer systems.
Mr McKinnon has previously lost appeals in the High Court and the House of Lords against his extradition, but two years ago a High Court judge ruled Mr McKinnon would be at risk of suicide if sent away.
Earlier this year Mrs May put the decision on hold to allow Home Office appointed psychiatrists to conduct an assessment.
They also concluded Mr McKinnon would be likely to take his own life if he was sent to face trial in the US.
Mr McKinnon was arrested in 2002 and again in 2005 before an order for his extradition was made in July 2006 under the 2003 Extradition Act.