While their deportation hearings, which can take years, are in process, the government is required to place them in the least restrictive environment available, usually with a parent or relatives or in foster care. However, a minority of them remain in detention, in facilities overseen by the Office of Refugee Resettlement, an agency of the Department of Health and Human Services.

“What we were seeing is that certain kids that the Office of Refugee Resettlement thinks are a flight risk or a danger were being detained without any judicial process to release them,” said Holly Cooper, a lawyer on the case.

“On behalf of those kids, we would go to immigration court and say we want a bond hearing, referring to the settlement, but the government would say there’s no bond hearing,” said Ms. Cooper, who is also co-director of the law clinic at the University of California, Davis.

As a result, she said, immigration judges said they had no power to set bond for the children’s release.

Immigrant advocates hailed the decision, saying that it would rein in the Trump administration’s immigration enforcement efforts.

“We are celebrating this decision because it gives a neutral forum to challenge overzealous enforcement and, most importantly, allows us to advocate for the best interests of the children,” said Lenni Benson, a professor at New York Law School.

If it stands, the ruling could add to the government’s backlog of more than half a million cases in immigration court. In the meantime, the administration has said it will begin arresting undocumented parents on criminal smuggling charges if they are suspected of hiring coyotes, or smugglers, to bring their children from Central America to the United States.