Theresa May said she was deeply saddened by his death and her thoughts and prayers were with his parents.
His parents accepted he had no realistic prospect of improvement, blaming the deterioration in his muscles while they were battling with the hospital, whose doctors believed the experimental treatment would not work and only prolong Charlies suffering. However, they fought further battles against Gosh in increasingly acrimonious proceedings.
They pleaded for Charlie to be allowed to die at home, describing it as their last wish.
In the face of opposition from Gosh, which said the invasive ventilation required by Charlie was not deliverable at home, they agreed with the hospital that he would be transferred to a hospice for his final hours.
But still the parties disagreed, with the family wanting to keep him alive for several days but the hospital saying that would require a 24/7 intensive care team, which was impossible to find for a hospice setting.
The judge, Mr Justice Francis, gave the parents time to find such a team but they were unsuccessful and he directed that an alternative plan should be put in place involving a much shorter time spent at the hospice on life support, the details of which were were not made public.
Hundreds of people, who called themselves Charlies Army, supported the campaign for him to receive treatment in the US, raising 1.35m.
A spokeswoman for Gosh said on Thursday: The risk of an unplanned and chaotic end to Charlies life is an unthinkable outcome for all concerned and would rob his parents of precious last moments with him.
As the judge has now ruled, we will arrange for Charlie to be transferred to a specialist childrens hospice, whose remarkable and compassionate staff will support his family at this impossible time.
Charlie had a form of mitochondrial disease, a condition that causes progressive muscle weakness and brain damage, although his parents claimed the hospital was wrong in saying he had already suffered severe irreversible brain damage. Yates and Gard also disputed with Gosh that their son was in pain.
Described as perfectly healthy when he was born, Charlie was admitted to hospital at eight weeks and his condition progressively deteriorated.
The couple said they wanted to take their son across the Atlantic for nucleoside bypass therapy and Charlies case became world famous, with the pope and Donald Trump intervening on behalf of his parents.
Earlier this month, Pope Francis said he had been following the case closely and hoped that Charlies parents would be able to accompany and treat their child until the end. The Vatican childrens hospital offered to take over his care from Gosh.
Shortly afterwards, Trump tweeted: If we can help little Charlie Gard, as per our friends in the UK and the pope, we would be delighted to do so.
Judges at the European court of human rights refused to intervene in the case late last month
Gard and Yates, both in their 30s from Bedfont, west London, went back to the high court this month after claiming they had new evidence of the prospects of the NBT therapy being successful. But at an emotional court hearing on Monday, which saw both parents in tears, as well as lawyers, members of the public and journalists, they said they were finally abandoning the case, paying tribute to Charlie as an absolute warrior.
Yates read a statement from the witness box in the packed courtroom in central London saying: Mummy and Daddy love you so much, Charlie, we always have and we always will, and we are so sorry that we couldnt save you. We had the chance, but we werent allowed to give you that chance. Sweet dreams baby. Sleep tight, our beautiful little boy.
Yates said time had been wasted and had Charlie been given the treatment sooner, he would have had the potential to be a normal, healthy little boy.
Doctors at Gosh did not agree, with lawyers representing the hospital saying the clinical picture six months ago had shown irreversible damage to Charlies brain.
Some of the Charlies Armysupporters made death threats against Gosh doctors and staff, earning condemnation from Gard and Yates.
A hospital spokeswoman said on Friday: Everyone at Great Ormond Street Hospital sends their heartfelt condolences to Charlies parents and loved-ones at this very sad time.