A panel of judges on Thursday dismissed an appeal by the U.S. government that contended detained immigrant children might not require soap during shorter stints in custody under a longstanding settlement agreement.

A three-judge panel for the Ninth U.S. Circuit Court of Appeals in San Francisco dismissed a challenge to a lower court decision that authorities had failed to provide safe and sanitary conditions for the children under the 1997 settlement.

The U.S. government had argued that authorities weren't required to provide specific accommodations, such as soap, under the agreement's requirement that facilities be "safe and sanitary" and asked the panel to weigh in. The appellate judges disagreed and dismissed the government's case.

"Assuring that children eat enough edible food, drink clean water, are housed in hygienic facilities with sanitary bathrooms, have soap and toothpaste, and are not sleep-deprived are without doubt essential to the children's safety," the panel wrote.

The ruling followed a June hearing where a U.S. government lawyer said the agreement was vague and didn't necessarily require that a toothbrush and soap be provided to children during brief stays in custody.

Children line up to enter a tent at the Homestead Temporary Shelter for Unaccompanied Children in Homestead, Fla., in February 2019. (Wilfredo Lee/The Associated Press)

U.S. District Court Judge Dolly Gee in Los Angeles ruled in 2017 that authorities had breached the agreement — widely known as the Flores settlement — after young immigrants caught on the border said they had to sleep in cold, overcrowded cells and were given inadequate food and dirty water.

Since then, problems in the facilities have persisted. Gee has appointed an independent monitor to evaluate conditions.

The issues date back years, but they have drawn increased attention amid a rise in the number of children and families, mostly from Central America, arriving on the southwest border.

The Flores settlement between advocates for young immigrants and the U.S. government says children should be held in facilities that meet certain standards and released as soon as is reasonably possible, which has been considered to be about 20 days.