US authorities were not given any warning about the decision, which was taken by the Home Secretary only yesterday morning.
Mr McKinnon would have faced 60 years in prison had he been found guilty in a US court of carrying out the largest ever infiltration of military computers from his north London home.
He won his 10-year battle against extradition, which his mother described as a "victory for the little person", after Mrs May said there was a risk he could kill himself if he was sent to America. The 46-year-old has been diagnosed with Asperger's syndrome and depression.
Mrs May told David Cameron and Nick Clegg of her decision before the Cabinet met at 10am.
US officials said privately that the decision was "frustrating", but that there was unlikely to be any long-term concern for relations with Britain. Victoria Nuland, a spokesman for the state department, said: "The United States is disappointed by the decision to deny Gary McKinnon's extradition to face long overdue justice. We are examining the details of the decision."
Mr McKinnon was arrested in 2002 after a series of hacks on military sites including the Pentagon and Nasa, which US authorities say caused £500,000 worth of damage. He claimed that he was looking for evidence of UFOs.
Mrs May told MPs there was "no doubt" that Mr McKinnon was "seriously ill". She said that after taking extensive legal advice, she concluded that his extradition "would give rise to a high risk of him ending his life". "The decision to extradite Mr McKinnon would be incompatible with his human rights," she said.
It will now be for Keir Starmer QC, the Director of Public Prosecutions, to decide whether Mr McKinnon should face charges in Britain.
Mrs May announced other changes, including a so-called "forum bar" to enable British courts to decide whether a person should stand trial in the UK or abroad. Future extradition decisions would be made by judges rather than home secretaries, she said.
Janis Sharp, Mr McKinnon's mother, said the past 10 years had been "horrendous" because her son would "just sit in the dark all the time".
"You saw him shut down and slow down. It's been awful watching Gary go downhill so badly, but such a relief to watch him smile for the first time in many years, it's amazing."
She said he could not speak when he heard the news. "It's been a life-saving decision because Gary doesn't travel abroad, he doesn't go on holiday, he very rarely leaves north London, and to be taken from everything you know, your family, thousands of miles away is so terrifying to him. I can understand that he felt he would rather be dead," she said. Asked about the possibility of a trial in Britain, she added: "He's lost 10 years of his life, but if this happens as well, we can deal with that."
Among the US allegations is the claim that Mr McKinnon hacked into 26 navy computers responsible for restocking the Atlantic Fleet with ordnance and ammunition. Two weeks after the September 11 attacks, he brought down a network of more than 300 computers used to monitor warships, Mark Summers, a US government lawyer, told an extradition hearing in London.
Mrs May was criticised for playing politics and even jeopardising relations with the US. Alan Johnson, the former home secretary who in 2009 approved the extradition, told MPs the ruling was "in her own party's best interest; it is not in the best interests of the country".