LONDON — The parents of Charlie Gard, the chronically ill British infant whose plight drew attention from Pope Francis and President Trump, on Monday gave up their wrenching legal effort to artificially prolong his life, bowing to the consensus of medical experts who said there was no realistic chance of saving him.

Breaking into tears as she stood in court, the child’s mother, Connie Yates, said she and her husband, Chris Gard, “only wanted to give him a chance of life.” She added that “we have decided to let our son go” because there was no prospect of meaningful improvement in his quality of life.

The High Court judge hearing the case, Nicholas Francis, praised the parents for their determination to help their son. “No parent could have done more for their child,” he told them, adding that the only appropriate course was “to let him die with dignity.”

Many in the courtroom wept.

By withdrawing their last-ditch pleas to compel the hospital that is treating their son to subject him to an experimental therapy, the parents essentially ended a thorny bioethical case that had divided global opinion. “Time has run out,” the parents’ lawyer, Grant Armstrong, told the court.