Doctors can withdraw life support from sick baby Charlie Gard against his parents' wishes, a High Court judge has ruled.
The eight-month-old's parents, Chris Gard and Connie Yates, from west London, were seeking permission to take him to a hospital in the US for a trial treatment.
A lawyer for the couple said they were "devastated" by the ruling.
Doctors had argued that the boy, who suffers from mitochondrial disease which causes progressive muscle weakness and brain damage, should be moved to a palliative care regime.
Mr Justice Francis made the ruling following a three-day hearing in the Family Division of the High Court in London.
He also visited Charlie at Great Ormond Street Hospital.
He said he had come to the decision with the "heaviest of hearts", but with "complete conviction" for Charlie's best interests.
"I find it is in Charlie's best interests that I accede to these applications and rule that Great Ormond Street may lawfully withdraw all treatment save for palliative care to permit Charlie to die with dignity," he said.
"I want to thank the team of experts and carers at Great Ormond Street, and others who cannot be named, for the extraordinary care that they have provided to this family.
"Most importantly of all, I want to thank Charlie's parents for their brave and dignified campaign on his behalf, but more than anything to pay tribute to their absolute dedication to their wonderful boy, from the day he was born."
Solicitor Laura Hobey-Hamsher said Charlie's parents were "devastated" and are struggling to understand why the judge had not "at least given Charlie the chance of treatment".
She said: "Lessons do however need to be learned about how medical professionals face decisions such as this, how they act with sufficient speed, and how they communicate with the families of desperately ill children, such as Charlie.
"It is regrettable and inexplicable that much of the reasoning for their decisions only came to light after proceedings had been issued.
"It is too simplistic to say that had matters been handled better, Charlie would be well, but undoubtedly, it did not assist."
She added that Charlie's parents wanted to thank the media and the public for their generosity and support.
Charlie was born on 4 August, 2016 with the rare genetic condition.
His parents launched a GoFundMe appeal to raise funds for his treatment two months ago, and reached their £1.2m target on Sunday following donations by more than 80,000 people.
A spokesman for GoFundMe said it would have talks with Charlie's parents over what will happen with the money raised for his treatment.
Great Ormond Street Hospital said in a statement: "We cannot imagine how hugely distressing this time must be for Charlie's family who have been completely devoted to him since he came to our intensive care unit six months ago.
"Our focus now is to work with Charlie's family to plan for the next stages in Charlie's care."