The 11-month-old baby, who suffers from an extremely rare genetic condition causing progressive brain damage and muscle weakness, has been the subject of a bitter dispute between his parents and Great Ormond Street Hospital in London.
The case has triggered a heated international debate in the press and on social media about who should decide a child's fate, and has drawn comment from U.S. President Donald Trump and Pope Francis.
Having reluctantly taken the decision over the weekend to let Charlie die, his parents have been making desperate attempts to make an arrangement that would make it possible for them to spend several days with him, away from hospital.
Charlie requires invasive ventilation to breathe and cannot see, hear or swallow.
At stake in this final, agonising part of the legal dispute is how long Connie Yates and Chris Gard will have with their son before he dies.
The parents tried for several days to gain permission to take their son home, but as Wednesday's court hearing progressed it became clear that would not happen because the logistical problems were insurmountable.
The parents had made clear that if they could not take Charlie home, they would prefer him to die in a hospice rather than in the hospital, where he has spent most of his life.
But a lawyer for Charlie's court-appointed guardian told the court that no hospice could provide care for intensively ventilated children for a long time, so the parents' wish to spend several days with him could not be fulfilled.
The parents have been trying to find a doctor willing to oversee a plan that would allow Charlie to be ventilated in a hospice for several days. It was to give them a final chance of making such an arrangement that the judge gave them until noon on Thursday.
"Unless by 12 noon tomorrow the parents and the guardian and the hospital can agree an alternative arrangement, Charlie will be transferred to a hospice and extubated shortly after," said Nicholas Francis, the judge presiding over the case.
Mother in tears
An alternative arrangement appears unlikely, given the total breakdown in relations between the parents and the hospital.
At one point, Yates shouted in court, apparently at Charlie's guardian: "What if it was your child? I hope you are happy with yourself." She then left the courtroom in tears.
At the start of the hearing, the parents' lawyer Grant Armstrong had said they had found a doctor who could help them.
But the guardian's lawyer, Victoria Butler-Cole, later said the person in question was a general medical doctor with no experience of intensive care, and that he had not identified any hospice willing to undertake intensive care for a long period.
Butler-Cole said the parents should spend the last few days of Charlie's life with him, not with their lawyers.
The dispute first made headlines months ago, when Charlie's parents wanted to take him to the United States to undergo experimental treatment.
The Great Ormond Street doctors said it would not help and would only prolong the baby's suffering. British courts, backed by the European Court of Human Rights, refused permission, saying the parents' plan was not in Charlie's best interests.
The parents gave up the legal battle on Monday, saying that the latest scans showed Charlie's condition had deteriorated to the point that no recovery was possible. But they remain convinced that the treatment might have helped Charlie had he received it months ago.
The hospital disagrees. It says Charlie had suffered irreversible brain damage by January as a result of a series of seizures, and his responsiveness has not changed since then.
(Writing by Estelle Shirbon; Editing by Alison Williams and Gareth Jones)
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)