A federal judge Friday rejected a sweeping Trump administration effort to detain migrant families and children for longer periods of time than currently allowed, saying it violates the very court settlement the government sought to scrap with its plan.

That settlement, known as the Flores Agreement, sets sweeping standards for the treatment of unaccompanied migrant children, from housing to medical care as well as education, nutrition and hygiene. In more recent rulings, Judge Dolly Gee has also effectively prohibited the government from detaining for more than 20 days families apprehended with children.

Attorneys outside the courthouse in Los Angeles hailed Gee's permanent injunction preserving the landmark 1997 settlement. They said the judge appeared unimpressed with the government's efforts in the case.

Get Breaking News Delivered to Your Inbox

"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.

The permanent injunction was issued after the hearing Friday.

The Flores Agreement has faced waves of criticism from federal officials coping with cyclical surges of unaccompanied migrant children, leading to unsuccessful attempts by both the current White House and the administration of former President Obama to alter it. Ultimately, on August 21, the Trump administration unveiled a Final Regulation on the care of migrant children and families that it believed would render the Flores Agreement obsolete.

In her order, Gee wrote the government's efforts failed "to implement and are inconsistent with" the Flores Agreement. In an accompanying filing Gee said the settlement was a contract that the government is unable to void.

"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," Gee wrote.

In briefs filed for Judge Gee, the government claimed that immigration has changed in the 22 years since the Flores Agreement was first established, and argued that the agreement itself led to an increase in children and families coming to the U.S.

In response, lawyers opposing the government action wrote that the government was attempting to "light a match" to the Flores Agreement with a "dizzying array" of claims about migrant children and families that federal courts had already rejected.

In the brief, filed in the U.S. District Court for the Central District of California, attorneys cited experts who said in attached declarations that complex, local socioeconomic factors cause families with kids — or children traveling without families — to uproot their lives. Those factors include gang violence, extreme poverty and local government corruption.

Congressman Joaquin Castro, chairman of the Congressional Hispanic Caucus, said in a statement that he is "pleased" with Friday's ruling, and that "we must protect Flores from any attempts by Trump Administration to undermine it in the court of law and the halls of our government."

"Flores is not a loophole — it's a lifesaving standard that protects the basic rights and dignity of migrant children," the Texas Democrat said.

Desai said she expects the government to appeal the ruling.

"We know the fight's not over, and we're here to defend the Flores Agreement to wherever it goes, and whatever it takes," Desai said.