Charlie Gard's parents ended their legal fight over the terminally ill infant's treatment July 24. Here's what you need to know about the legal battle over his life. (Monica Akhtar,Elyse Samuels/The Washington Post)

LONDON — For much of their son’s short life, Charlie Gard’s parents toggled between two worlds.

One was the hospital bedside, where their gravely ill baby was kept alive by machines.

The other was the courts, where Connie Yates and Chris Gard argued passionately that Charlie should be given one more chance to beat the rare genetic condition that his doctors had concluded would inevitably cause his death.

On Monday, the parents gave up their court fight, acknowledging that time had run out and that their son would die within days, not living to see his first birthday on Aug. 4.

“We are about to do the hardest thing we will ever have to do, which is to let our beautiful little Charlie go,” Chris Gard said as he stood in front of the gothic stone of London’s High Court building alongside Yates. Both choked back tears, with onlookers — including protesters — openly weeping.

Gard and Yates spent Tuesday trying to persuade the hospital and a judge to let them say goodbye to Charlie at home. Hospice was the second-best option, their attorney told a judge at a hearing.

Yates and Gard want Charlie with them at home several days before he receives palliative care, according to the Mirror. They have offered to pay for a mobile ventilator and medics so the infant can leave the hospital, according to the Sun.

The hospital said Charlie's invasive ventilation is a significant obstacle to his parents' wishes. A complication could arise while he is being moved to his parents' home. And their front door may be too small for hospital equipment to fit through.

It was the final dispute in an acrimonious and bitter legal battle that has brought global attention to Charlie’s plight and drawn interventions from figures as disparate as Pope Francis and President Trump.

The case has pitted the rights of Charlie’s parents to decide what’s best for their son against the obligations of doctors to spare the baby what they have described as a life defined only by pain and suffering.

Charlie’s parents insisted Monday that he might have been saved had it not been for the legal roadblocks thrown up by the hospital that provided his care and that he had missed his chance to receive an experimental treatment in the United States.

“Had Charlie been given the treatment sooner, he would have had the potential to be a normal, healthy little boy,” Chris Gard said. “We will have to live with the what-ifs that will haunt us for the rest of our lives.”

As it has throughout the case, the hospital where Charlie Gard is being treated, London's Great Ormond Street Hospital (GOSH), sharply contested that view, empathizing with Charlie’s parents but maintaining that his case has long been hopeless — and that prolonging his life was not in Charlie’s best interest.

In a court session Monday that had been expected to include more arguments over Charlie’s fate but was cut short by the surprise announcement by the parents, hospital attorney Katie Gollop said that “the agony, desolation and bravery of their decision command GOSH’s utmost respect and humble all who work there.”

But she added that although the hospital had sought “to work with them throughout, Charlie’s needs have taken priority.”

The hospital has maintained that the treatment sought by Charlie’s parents had never been used on either a human or animal with Charlie’s condition, and that by the time it was proposed, Charlie had suffered irreversible brain damage.

GOSH said Charlie's parents were given false hope by Dr. Michio Hirano, the Columbia University neurology professor who said his nucleoside bypass therapy could cure the boy. In a statement, the hospital said Hirano had not visited Charlie, viewed his brain imaging or read any of the second opinions about the case. The doctor also had a financial interest in some of the compounds he wanted to prescribe for Charlie, the hospital said.

Through it all, Gollop argued Monday, Charlie has been in pain.

“If Charlie has had a relationship with the world around him since his best interests were determined, it has been one of suffering,” she said.

Charlie has mitochondrial DNA depletion syndrome, a rare genetic condition that has robbed him of the ability to see, hear, move or breathe on his own.

His parents’ decision to stop their legal fight drew expressions of commiseration and sorrow on Monday.

U.S. lawmakers, many of whom began to focus on the case after Trump tweeted July 3 that the United States would be “delighted” to help, also expressed solidarity with Charlie and his family.

Two members of Congress even offered to introduce a bill that would give Charlie and his parents permanent U.S. residency.

One of the lawmakers, Rep. Trent Franks (R-Ariz.), tweeted Monday that it was “a sad day. My prayers go out to the Gards who have to be heartbroken.”

The Oxford-based Anscombe Bioethics Center, which uses Catholic teachings to analyze medical practice and research, said that “a time will come to look at what went wrong in this case” — but that that could wait for another day.

“Now is the time to remember the preciousness of the child at the heart of this case, and to allow his parents to be with him until he passes from this life,” the center said. “If further treatment may no longer be worthwhile, Charlie's life is inherently worthwhile.”

Outside the court, meanwhile, the mood was somber — but also angry.

Protesters who have labeled themselves “Charlie’s Army” reacted furiously to the announcement that the legal fight would end. They chanted “Shame on you, judge!” and “Shame on GOSH!”

The protesters have included activists from the United States, many of whom have seen the case as a galling instance of the state trampling on the wishes of parents who, above all, have wanted to give their child a chance.

The hospital said it had received a “disgraceful tide of hostilities,” and even death threats, all of them directed at “doctors and nurses whose life's work is to care for sick children.”

But Claire Fenton-Glynn, who specializes in children’s rights as a law lecturer at the University of Cambridge, said the hospital and courts had behaved appropriately — carefully considering the parents’ arguments but, in the end, deciding what is best for Charlie.

“It’s the role of the state and the courts to make an objective assessment of where the child’s best interests lie,” she said. “It’s a devastating case on a human level. On a legal level, it’s not as controversial.”

In the end, Charlie's parents said they gave up on their court fight because the doctor who pioneered the experimental treatment believed it was no longer viable for Charlie, who was too far gone.

Speaking in front of a phalanx of news cameras outside the courthouse on Monday, Gard and Yates said they planned to retreat from the public eye so they could spend “our last precious moments with our son.”

The last words of their tear-filled statement were for him:

“To Charlie, we say: Mummy and Daddy, we love you so much. We always have and we always will and we are so sorry that we couldn't save you. Sweet dreams, baby.”

— Wootson reported from Washington.

Read more:

Fla. mayoral candidate had a message for activists who want reparations: ‘Go back to Africa’

‘Tell them Chrissy sent you’: London attack victim’s life inspires people to help the homeless

An 8-year-old was separated from her family after the Manchester attack. She never made it out.

Sikh community asks for hate-crime probe after man is told ‘go back to your own country’ and shot