The Trump administration said Thursday it plans to circumvent a longstanding court agreement that governs how children are treated in immigration custody, in part to detain families longer as a way to deter migrants from crossing the Southwestern border illegally.

The Department of Homeland Security announced proposed regulations that would terminate the so-called Flores agreement that requires the government to keep children in the least-restricted setting and required their release generally after 20 days in detention.

The 1997 case that spawned the agreement will almost certainly land back in court. U.S. District Court Judge Dolly M. Gee rejected a request by administration lawyers this summer to allow for longer family detention.

Get Breaking News Delivered to Your Inbox

The agreement became an issue during a "zero-tolerance" policy enforced at the border to criminally prosecute anyone caught crossing illegally.

More than 2,900 children were separated from their parents, prompting international outrage and scathing criticism over what many said was inhumane treatment of migrants. Officials said children couldn't be in criminal custody with their parents, and were limited in how long they could detain families because of the agreement.

The DOJ has attempted to petition the courts to remove the 20-day limit on detaining immigrant families together, but has, as of yet, been unsuccessful.

The government currently has three operational family detention centers, but most are at capacity.

However, DHS asked for space to house 12,000 beds for families, plus space to house 20,000 unaccompanied minors. That process is moving forward; the Defense Department has completed legal and environmental requirements needed but they're still working on the legal framework for the use of Fort Bliss, in El Paso, Texas for immigrant families. The Department of Health and Human Services, which manages unaccompanied children crossing illegally, has not yet formally requested space for the minors, which it must do in order to set up the use.

The rules proposed Thursday would allow the government to hold families until their immigration cases were completed, a move that government officials contend makes cases go much faster than if families are released.

"Today, legal loopholes significantly hinder the department's ability to appropriately detain and promptly remove family units that have no legal basis to remain in the country," said DHS Secretary Kirstjen Nielsen. "This rule addresses one of the primary pull factors for illegal immigration and allows the federal government to enforce immigration laws as passed by Congress."

As of last week, hundreds of children were still separated from their parents at the border.

Family separations became one of the most controversial actions of the Trump administration in recent months. Trump daughter and top aide Ivanka Trump called the separations a "low point" for her. Sen. Lindsey Graham, R-South Carolina, recently mentioned the "zero-tolerance" policy when asked if there was any credible basis for Mr. Trump to potentially fire Attorney General Jeff Sessions.

Immigrant advocates have opposed any effort to detain children longer than the agreement allows, and responded immediately to the proposed rule Thursday.

"By eroding the limited protections against mistreatment that detained children have through the Flores Settlement Agreement, we can expect even more children to be subjected to drastically worse detention conditions and our society as a whole will suffer from the long-term consequences of the trauma that our government is inflicting on children," Rachel Prandini, staff attorney at the Immigrant Legal Resource Center, said in a statement.

"Both family separation and the detention of children have been condemned by leading medical professionals and the American Academy of Pediatrics as having the potential to cause negative health effects that can last a lifetime. The Trump administration's decision to exacerbate the suffering of kids, by imposing the cruel policy of family separation earlier this summer and now with this rule change to vastly expand detention of children, is horrifying."