A federal judge on Friday blocked the Trump administration from enacting new regulations that would allow migrant children to be detained with their families indefinitely.

U.S. District Judge Dolly Gee in Los Angeles ruled that the new policy violates the Flores Settlement Agreement, a 1997 federal consent decree that outlines how migrant children should be treated in government detention and how long they can be held.

The government is expected to quickly appeal Gee's ruling and the case may end up before the Supreme Court.

The ruling is a major setback for the administration, which has been focused on nullifying the Flores agreement. Administration officials argue that the agreement, which has been interpreted to limit the time migrant children can spend in detention to 20 days, creates a "catch and release" system that encouraged migrant families to come to the U.S., knowing they will be released to await court proceedings.

The new policy was set to go into effect on Oct. 22. It would have done away with limits on child detention and created a new licensing scheme for detention facilities, allowing Immigration and Customs Enforcement to set its own standards for care at those facilities.

The regulations, which were proposed last month, were widely panned by immigrant rights groups and child advocacy organizations.