The home secretary Theresa May has ruled against extraditing hacker Gary McKinnon to US over fears about the state of his mental health.

Her decision came after a 10-year-legal battle by the Glasgow-born hacker against extradition after he allegedly gained access to 97 military and Nasa computer systems.

McKinnon was diagnosed with Asperger's syndrome - a form of autism - in 2008. A medical review ordered by the Home Office concluded that it was likely he would take his own life if he were extradited.

May announced Keir Starmer, the Director of Public Prosecutions, will decide if McKinnon should face trial in a British court.

Speaking to the House of Commons, May said: "Mr McKinnon is accused of serious crimes, but there is no doubt he is also seriously ill. He has Asperger's syndrome and suffers from depressive illness."

"After careful consideration of all the relevant material, I have concluded that Mr McKinnon extradition would give rise to such a high risk of him ending his life that a decision to extradite him would be incompatible with Mr McKinnon's human rights."

McKinnon admitted to hacking into US government and military websites from his bedroom in north London but claimed he was only doing so to look for evidence of UFOs.

He faced up to 60 years in jail for what has been described by US authorities as "the biggest military computer hack of all time".

The home secretary also told Parliament that she would introduce new extradition measures known as a forum bar, which would make it more likely for British citizens to face triial in the UK for crimes committed here.

McKinnon's mother, Janis Sharp, told the BBC of the dangers the 46-year-old faced if he were extradited.

She said: "For 10 years he has lived a zombiefied life and it has destroyed him and it has destroyed our lives.

"The doctors and the Home Office psychiatrist have all said Gary will take his own life, not could or might, he will if extradition proceeds and there is nothing they can do to stop it."

Blood on my hands

David Burrowes, the Conservative MP for Enfield Southgate and McKinnon's MP, said before the announcement he would resign from his role as parliamentary private secretary to the environment secretary Owen Paterson if the 46-year-year-old were extradited.

Burrowes said: "I don't want blood on my hands and also I hold firm to the promises we made and want to follow through with those."

The extradition laws agreed with the US were created in the wake of 9/11. A UK citizen can be extradited to the US without probable cause, but not the other way around.

Sharp added: "This was supposed to be for terrorists - if you were in a country and you committed a heinous crime and you fled - it wasn't meant for this kind of thing."

Shami Chakrabarti, director of Liberty, welcomed the decision by May.

She said: "Extradition should prevent fugitives escaping - not allow for Britons like Gary to be parcelled off around the world based on allegations of offences committed here at home.

This campaign, led by Gary's fearless mother, united lawyers, politicians, press and public from across the spectrum in the cause of compassion and common sense.

The case has echoed that of TVShack founder Richard O'Dwyer, who was extradited to the US to face trial over copyright infringement charges despite not breaking any laws in the UK.

TVShack was a website set up by O'Dwyer from the UK which American authorities claim hosted links to pirated copyrighted films and television programmes, but did not host the material itself. He faces up 10 years in prison.