Doctors can stop providing life support to toddler Alfie Evans against his parents' wishes, the High Court has ruled.
Alder Hey Children's Hospital argued that continuing to treat the 21-month-old, who has a mystery illness, was "unkind, unfair and inhumane".
His parents Tom Evans and Kate James had hoped to prolong Alfie's life with treatment at a hospital in Rome.
Mr Justice Hayden said Alfie requires "peace, quiet and privacy".
The hospital is set to withdraw ventilation on Friday.
His mother left the court hearing before the ruling while his father broke down as the decision was announced.
About 30 supporters of the family's campaign had gathered outside Alder Hey as the decision about his treatment was delivered.
The conclusion was made after a hearing at Liverpool Civil and Family Court earlier this month was told Alfie was in a "semi-vegetative state".
He has a degenerative neurological condition doctors had not definitively diagnosed, the court heard.
Mr Justice Hayden said he accepted medical evidence which showed further treatment was futile, adding: "Alfie's need now is for good quality palliative care."
Delivering the ruling in the High Court in London, he said he had reached his conclusion with great sadness.
He paid tribute to Alfie's parents and the staff at Alder Hey.
After the decision, Mr Evans said: "I need time to reflect on the judgement" while supporters of Alfie's campaign stood in silence wiping away tears and hugging each other.
The family is considering whether to appeal.
In a statement, Alder Hey Children's Hospital said it will continue to work with Alfie's family to agree the "most appropriate" palliative care plan for him during a "very difficult time".
It said it always aims to reach an agreement with parents about care plans.
"Unfortunately there are sometimes rare situations such as this where agreement cannot be reached and the treating team believe that continued active treatment is not in a child's best interests."
The hospital had referred the case to the High Court to determine what treatment would be in Alfie's best interests.