LONDON (AP) — A British judge ordered Thursday that critically ill baby Charlie Gard should be moved from a hospital to a hospice, where he will "inevitably" die within a short time.

As the medical and legal story that has sparked compassion and controversy around the world entered its final stage, the baby's dismayed mother accused courts and a hospital of denying Charlie's parents "our final wish" — to let their son die at home.

"We just want some peace with our son. No hospital, no lawyers, no courts, no media. Just quality time with Charlie away from everything to say goodbye to him in the most loving way," said Connie Yates. "I'm shocked that after all we've been through they won't allow us this extra time."

Eleven-month-old Charlie has brain damage and is unable to breathe or move his limbs unaided.

Judge Nicholas Francis made the hospice order after Charlie's parents and the hospital treating him failed to meet a deadline to agree on an end-of-life care plan that could have seen the baby kept alive for several more days.

The judge said that meant Charlie, who has a rare genetic disease called mitochondrial depletion syndrome, should now be transferred to a hospice and have the ventilator that keeps him alive removed.

The judge said that "will inevitably result in Charlie's death within a short period of time."

He barred identification of the hospice or of any of the medical staff treating Charlie, and ordered that there should be no media reports of when Charlie is moved.

His parents, Yates and Chris Gard, spent months trying to persuade London's Great Ormond Street Hospital to let Charlie go to the United States for an experimental treatment that they believed could help him. Charlie's doctors opposed the idea, saying it would not help and could cause Charlie more suffering.

British courts and the European Court of Human Rights all sided with the hospital in its bid to remove life support and allow Charlie to die naturally.

Earlier this week Charlie's parents gave up their legal fight, saying the baby's condition had deteriorated so far that the window of opportunity to help him had closed.

They then sought to take their son home to die, but Great Ormond Street Hospital said Charlie's complex needs made that impractical. At an emotional hearing on Wednesday, the judge said Charlie would, inevitably, end his days in a hospice. Yates left the hearing in tears, as the hospital and Charlie's parents continued to disagree on how long he should be kept on life support once he was taken to the hospice.

The heart-breaking case attracted international attention after U.S. President Donald Trump and Pope Francis expressed support for Charlie's parents. U.S.-based religious and anti-abortion activists flew to London to support the family's battle.

Charlie's case has become the catalyst for often-emotional debates about health care funding, medical intervention, the role of the state and the rights of the child.

The judge this week condemned social media commentators who discuss the case without knowing the facts.

Great Ormond Street, one of the world's leading children's hospitals, said the case had been "a uniquely painful and distressing process for all concerned," and it was sorry it had been played out in public.

"As the judge has now ruled, we will arrange for Charlie to be transferred to a specialist children's hospice whose remarkable and compassionate staff will support his family at this impossible time," the hospital said.

It said it was acting in the baby's best interests, because "the risk of an unplanned and chaotic end to Charlie's life is an unthinkable outcome for all concerned and would rob his parents of precious last moments with him."

"Every single one of us wishes there could have been a less tragic outcome," the hospital said. "Our thoughts and deepest sympathies go out to Chris and Connie, and we hope that their privacy is respected at this devastating time for their family."