(Reuters) - A U.S. federal judge on Monday rejected the Trump administration’s request to allow long-term detention of illegal immigrant children, a legal setback for President Donald Trump’s push to detain immigrant families taken into custody at the U.S.-Mexico border.

Los Angeles U.S. District Court Judge Dolly Gee dismissed as “dubious” and “unconvincing” the U.S. Justice Department’s proposal to modify a 1997 settlement known as the Flores Agreement, which says that children cannot be held in detention for long periods.

The government made its request in June after public outcry over its policy of separating children from parents who entered the United States illegally. A judge in a different case in San Diego ordered the government last month to reunite the families it had separated.

The government asserted in its Flores filing that the San Diego ruling would necessitate longer-term detention of children, since that would be the only way to both reunite them with their parents and keep the parents incarcerated during their immigration proceedings.

Gee rejected that argument.

“Defendants advance a tortured interpretation of the Flores Agreement in an attempt to show that the … injunction permits them to suspend the Flores release and licensure provisions,” she wrote.

Previous administrations often released families apprehended at the border to pursue their immigration claims while living freely in the United States. But Trump has vowed to end what he calls “catch-and-release.”

In a statement, U.S. Justice Department spokesman Devin O’Malley said the administration disagreed with the ruling but said it appeared to allow the government to continue some practices.

“Parents who cross the border will not be released and must choose between remaining in family custody with their children pending immigration proceedings or requesting separation from their children so the child may be placed with a sponsor,” he said.

The plaintiff’s attorney Peter Schey disputed that interpretation, saying the judge’s ruling deals with children and “does not address laws, regulations or rules dealing with the release of parents.”

Gee called the administration’s request for relief from the Flores agreement “a cynical attempt... to shift responsibility to the judiciary for over 20 years of congressional inaction and ill-considered executive action.”

Last week John Mendez, a U.S. District Court Judge in Sacramento appointed by former President George W. Bush, struck a similar note in a ruling on a case challenging California’s sanctuary law.

Mendez said he was joining an “ever-growing chorus” of judges to urge “elected officials to set aside the partisan and polarizing politics dominating the current immigration debate and work in a cooperative and bi-partisan fashion toward drafting and passing legislation that addresses this critical political issue.”