A federal appeals court panel ruled on Thursday that the government must provide detained migrant children with basic hygiene supplies such as toothbrushes and sleeping mats, ending a debate that incited national outrage after a Justice Department lawyer argued against the need to do so.

The exchange in June between the lawyer and a panel of openly aghast federal judges spread rapidly in the national media. The case grew in significance days later, when a group of lawyers told reporters they had observed distressed migrant children held in cramped, dirty conditions and without sufficient food or clean water at a Border Patrol station in Clint, Tex.

The lawyers said they saw infants being cared for by other detainees, some as young as 7 years old.

Lawmakers sprang into action, decrying the conditions. Hundreds of children were transferred out of the station, which was cleaned up, and the top Border Patrol agent who oversaw the facility was reassigned before resigning from his job.

“It’s a major victory for children in federal immigration custody,” Elora Mukherjee, one of the lawyers who visited the Clint facility and who has served as an official monitor on the ongoing court case for several years, said of the court’s decision.