The little boy has, Mr Justice Ryder ruled, no chance of recovering from lung failure and has had a 'tragic decline in health'. He said it would be wrong to keep him alive.
He added that it was with a 'heavy heart' that he reached his decision, and paid tribute to the child's Christian family - who had told the High Court that they believed he was still conscious and that their was a chance the Lord could save him.
Mr Justice Ryder agreed that the family provided him with comfort, and their presence would be in keeping with their faith, but said that the boy was at risk of further complications and infection, and was already seriously ill.
He said: "I hope that he continues to live his life with dignity and when his life ends his family will understand that he lived it to the full."
The judge had heard that the schoolboy - whose name has not been released - had been born prematurely and had undergone surgery as an infant to repair holes in his heart.
His health deteriorated after he had surgery in June to remove a band that had been put around his pulmonary artery. A life-support machine had taken over the functions of his heart and lungs, and he was on ventilation.
He showed no improvement after a month, and doctors were giving him more and more sedation.
Mr Justice Ryder said that it was the 'view of the hospital team that there is no prospect of his heart or lungs recovering and therefore no hope of survival'.
The boy's parents refused to give their consent to treatment being withdrawn when clinicians decided last week that their was no hope for the child. The family instructed their lawyers to challenge the hospital's decision in court.
The child's mum said she accepted the doctors' diagnosis, but that her son was still aware of her, and she, his father and three siblings had not given up hope.
"Unexpected things can happen and because of faith and my trust in God and my understanding that he is the one who gave him life he is the one alone who can end that life, I cannot agree to the lifeline of oxygen being taken away from him. God could intervene in a miraculous way," she said.
She added that she and the family did not think it was their place or that of doctors to end his life, saying it would be a 'betrayal of trust' if they did.
More:Advice And Health
Suggested For You
SUBSCRIBE AND FOLLOW
Get top stories and blog posts emailed to me each day. Newsletters may offer personalized content or advertisements.Learn more