A severely disabled prisoner who requires round-the-clock treatment does not have to go back to jail, the Court of Appeal has ruled.
Daniel Roque Hall, 30, is serving a three-year sentence after admitting smuggling 2.8kg of cocaine in his wheelchair back from a holiday in Peru.
He suffers from the rare degenerative condition Friedreich's ataxia and is not expected to live into his 40s. He has spent most of his sentence in hospital.
Allowing his appeal against sentence, Lord Justice Hughes, Mr Justice Wyn Williams and Mr Justice Hickinbottom substituted the lesser term of 18 months, which means he can return to his north-west London home this week.
Campaigners had argued that Hall's sentence was "the death penalty by default".
Hall's mother Anne, who joined supporters who clapped as the appeal judges announced their decision, said she was "absolutely delighted" with the court's decision to release her son.
She said: "The court has made a right and just decision for which I am grateful.
"It is important for people with disabilities that their needs are properly understood and prisons can cater for them in the way they would be treated in the community.
Mrs Hall said it was a pity the prison authorities did not draw on the "deep knowledge" of the organisation Ataxia UK.
She added: "Ataxia UK said in July that sending Daniel to Wormwood Scrubs for three years was a death sentence, and the seven weeks he spent there did almost cost him his life."
Lord Justice Hughes said there was no lack of punishment in what he had undergone since being sentenced last summer, and his case was "an appropriate case for an exceptional application of mercy".
Welcoming the court judgment, Juliet Lyon, director of the Prison Reform Trust, said: "Prison is a double punishment for a severely disabled person."
The court was told of his fear of dying if he is sent back to Wormwood Scrubs in west London because the prison cannot meet his complex care needs.
Hall was taken to University College Hospital last August after his health deteriorated in the jail and since then has been kept in hospital under prison guard.
Although they are allowing Hall to return home, the judges made an order under the Serious Crime Act 2007 requiring him to surrender to the police his two passports - one British and one Nicaraguan - and not to travel abroad for three years from the date of his original conviction.
Lord Justice Hughes said the travel ban was necessary to counter any risk of him becoming involved in further offending, adding: "It is necessary because of the risk which affects him as well as other people".
Last month Hall won a High Court injunction preventing the prison service from returning him to jail pending Friday's ruling.
Protesters had demonstrated outside Wormwood Scrubs after he was told he would be sent back.
Hall pleaded guilty to smuggling 2.8kg of cocaine out of Peru at Isleworth Crown Court in February last year and was sentenced in July.
The court heard he had could not have acted alone and may have been "groomed" online.
Friedreich's ataxia affects body co-ordination and causes diabetes and a heart defect which requires constant monitoring.
Hall was rushed to hospital last August and placed on a life support machine when his condition worsened.
Hall's family said the two constant carers he needed were not supplied while he was in prison, and he had been denied vital medication and stretching exercises.
This had resulted in severe spasms, which affected his heart.
Lord Justice Hughes said in his written judgment it was "a very unusual case" in which the trial judge had to find the right sentence for a man suffering from "a grave combination of rare, long-term medical conditions" which were "quite dreadful" and interfered with virtually all his bodily functions.
Hall had become confined to a wheelchair 15 years ago and required 24-hour monitoring and a very high level of constant assistance.
His family had connections in South America, and his father was Nicaraguan.
He had travelled to Peru with his carer and committed a serious offence of importing into the UK a large quantity of cocaine with a high level of purity, worth about £370,000.
"The defendant was not exploited by someone else, nor does he suggest that he was blackmailed or put under severe pressure," said the judge.
"Severely disabled as he himself is, the quantity of the drug imported was capable of ruining the lives of many other people, either directly from taking it or via the harm that those who took it might do to others."
The court could not be sure whether his offending was prompted by resentment against society generally "attributable to the appalling handicaps life had visited upon him".
It was his first offence and he had demonstrated genuine remorse and been at pains to exonerate his carer. But the condition of gravely ill or severely disabled people who committed serious offences "cannot be a passport to absence of punishment", said the judge.
If Hall offended again punishment would inevitably be the outcome, with some loss of quality of care.
The judge added: "There is no lack of punishment in what he has undergone since being sentenced in the summer of last year.
"He is now said by the hospital to be significantly more frail than at the time of sentence."
The events of last August, when Hall had to be taken from prison to hospital, did not demonstrate any breach of human rights by the prison authorities.
But they did illustrate the "inherently unstable combination of conditions from which he suffers and the real potential for unexpected deterioration over a short period."
If the trial judge had known, "we think he would have felt able to make a significantly greater reduction in his sentence".
Later a Prison Service spokeswoman said: "We can confirm that the court did not uphold Daniel Roque-Hall's human rights allegations in respect to his treatment at HMP Wormwood Scrubs and concluded that the prison had not acted unlawfully.
"The Prison Service holds in custody those sentenced by the Courts and it is committed to treating all prisoners humanely and decently."