LONDON — Critically ill baby Charlie Gard will be transferred to a hospice and taken off life support unless his parents and a hospital agree on a plan that could potentially keep the child alive for a bit longer, a British judge ruled Wednesday.

High Court judge Nicholas Francis gave 11-month-old Charlie’s parents and the hospital that has been treating him until noon Thursday to come to terms on an end-of-life care plan for the infant.

The baby suffers from a rare genetic disease, mitochondrial depletion syndrome, which has caused brain damage and left him unable to breathe unaided. Recent tests found Charlie has irreversible muscular damage.

“It is in Charlie’s best interests to be moved to a hospice and for him at that point to be moved to a palliative care regimen only,” the judge said as a medical and legal battle that has drawn international attention nears a wrenching conclusion.

The parents, Connie Yates and Chris Gard, spent months trying to persuade Great Ormond Street Hospital to let Charlie go to the U.S. for experimental treatment. They gave up their fight Monday, acknowledging that the window of opportunity to help him had closed.

On Tuesday, they said they hoped to bring their son, whose first birthday is next week, home to die. Francis said Charlie’s mother and father now accept that the only options for their son “are the hospital or the hospice.”

The Thursday deadline is meant to yield a plan for what happens after the baby is transferred to a hospice. The parents want him kept on his ventilator for a time. Without an agreement, he will be taken to hospice and the ventilator will be turned off.