Charlie Gard will be moved to a hospice - unless his parents and Great Ormond Street Hospital can agree another plan by noon on Thursday (July 27), a judge has ruled.
Sitting at the High Court, Mr Justice Francis said the 11-month-old would be moved to a hospice and extubated unless alternative arrangements can be made.
The name of the hospice and when he is moved will remain confidential.
Connie Yates and Chris Gard had said they wanted Charlie to spend his final days with them at home.
But doctors caring for Charlie at Great Ormond Street Hospital in London say it is not practical to provide life-support treatment to Charlie at the couple's home, or indeed the home of a relative, for days.
Lawyers representing the couple on Wednesday (July 26) told the High Court about a change of heart. They said the couple now wanted a move to a hospice.
Grant Armstrong QC, representing Charlie's parents said that some nursing staff at Great Ormond Street Hospital have volunteered to spend their time off assisting Charlie in his final days.
But they said Charlie's parents were still in dispute with doctors over the detail of care plans.
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.
"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," Mr Justice Francis ruled.
The order was made after a private hearing to decide the exact timing of the move to a hospice as well as how long Charlie would be at the hospice before being extubated.
As the public re-entered the courtroom, Charlie's mother Connie Yates was weeping and shouted out "That's my baby" before storming out, yelling "I hope you're happy with yourself".
The remark appeared to be directed at the legal counsel for the court appointed guardian who represents Charlie's best interests, and the lawyer representing Great Ormond Street Hospital.
In a bizarre sequence of events, proceedings started with the announcement by Mr Armstrong QC that a doctor with experience in surgery and intensive care as well as a hospice and a team who could care for Charlie had been found, and was on his way to the court.
After a two-hour adjournment it emerged that the doctor was a private GP and did not have the experience or facilities that were claimed.
Mr Justice Francis added that he hoped this would be the final hearing in the case and that the parents would now be free to spend time with Charlie and the doctors could return to their normal duties.
He was also keen to issue a clarification that the state was not directly involved in Charlie's case as a direct result of 'socialised medicine' in the UK, as is being claimed by many Republican politicians and analysts in America.
"I am doing everything I possibly can to help the parents wishes but the notion that the state is involved because we have a National Health Service is preposterous"