Mr Justice Francis had set a timetable to govern the final period of the little boy’s life.
Doctors at Great Ormond Street Hospital and Charlie’s parents Chris Gard and Connie Yates disagreed over how long he should receive life-support treatment.
Medics said he should move to a hospice soon and life-support treatment should end shortly after his arrival.
His parents wanted more time with him and said he should receive life-support treatment for a number of days.
The judge on Thursday made public details of an order which will result in Charlie dying shortly after moving to a hospice.
Charlie’s parents became embroiled in the new fight with doctors over end-of-life arrangements earlier this week, a day after abandoning attempts to persuade the judge to let their son travel to America for experimental treatment.
Mr Gard and Ms Yates, who are in their 30s and come from Bedfont, west London, had asked Mr Justice Francis to rule that Charlie should be allowed to undergo a therapy trial in New York.
Doctors at Great Ormond Street said the therapy would not help. They said life-support treatment should stop.
Mr Justice Francis in April ruled in favour of Great Ormond Street and said Charlie should be allowed to die with dignity.
Charlie’s parents subsequently failed to overturn his ruling in the High Court, Court of Appeal and Supreme Court in London.
They also failed to persuade European Court of Human Rights’ judges to intervene.
But the couple had recently returned to court, saying they had new evidence, and asked Mr Justice Francis to change his mind.
They abandoned their legal fight on Monday after concluding that Charlie had deteriorated to the ‘’point of no return’’.
A statement issued by Great Ormond Street Hospital after the order was released said: “We deeply regret that profound and heartfelt differences between Charlie’s doctors and his parents have had to be played out in court over such a protracted period.
“It has been a uniquely painful and distressing process for all concerned.”
It added: “Every single one of us wishes there could have been a less tragic outcome.”