A US federal judge has issued a legal setback to the Trump White House's effort to expand detention for migrant children crossing the US-Mexico border.
The move to overturn strict limits on detention was an "obvious" violation of a longstanding policy towards child detainees, lawyers had argued.
Under the 1997 Flores Agreement, child migrants can only be kept for 20 days.
The ruling by Judge Dolly Gee in Los Angeles is temporary, but a formal written decision is expected in days.
The Trump administration has long argued that it needed to withdraw from Flores in order to tackle a growing humanitarian crisis at the country's southern border.
Peter Schey, a lawyer representing plaintiffs opposing the White House, said the president wanted to "detain children indefinitely".
The Flores Agreement also says children are entitled to appropriate food and hygienic supplies such as soap - another provision of the law that the White House has challenged.
Families found crossing the border with children are also only permitted to be detained for 20 days before being released.
Migrant advocates cheered the judge's bench decision outside the courthouse, saying the judge appeared unimpressed by the government's arguments.
"She did not hide her complete disregard for (the government's) failed attempts to withdraw from this settlement," said Neha Desai, the director of Immigration for the National Center for Youth Law.
In her order, Judge Gee wrote the government's efforts failed "to implement and are inconsistent with" the Flores Agreement.
In a separate filing, the judge added: "The blessing or the curse - depending on one's vantage point - of a binding contract is its certitude. The Flores Agreement is a binding contract and a consent decree."
The Trump administration is not the first to try to alter the agreement.
The Obama presidency also sought to amend it as the US faced waves on unaccompanied child migrants fleeing poverty and violence in Central America.