President Donald Trump reversed himself on Wednesday and signed an executive order that he said would end family separations at the U.S.-Mexico border – by instead sending parents and children together to family detention centers.

Trump’s order is likely to set up a legal challenge from advocates who will say it runs afoul of the 1997 Flores v. Reno settlement, which requires immigration officials to “place each detained minor in the least restrictive setting appropriate.”

Flores v. Reno also requires officials to release immigrants under 18 “without unnecessary delay,” meaning if they were not going to be prosecuted — and they had a family member to stay with — they could not be kept in a detention facility with their parents for long periods of time.

Trump acknowledged a possible legal show-down when he said during his announcement in the Oval Office, “There may be some litigation.”

In the order, Trump directed Attorney General Jeff Sessions to request to modify a settlement last year over the enforcement of the Flores ruling and try to get the courts to allow families to be detained together.

Trump’s order to keep families together in detention isn’t necessarily new. Barack Obama tried to keep asylum-seeking mothers with their children during his presidency before a court ruled against the practice in July 2015.

However, the courts struck down the Obama Administration practice, and the Trump Administration had cited legal precedent as the reason that U.S. Border Patrol agents were forced to separate families following its zero-tolerance policy of prosecuting every person caught crossing the border illegally.

In the 2015 case, Judge Dolly M. Gee of a Federal District Court in California rejected the Obama Administration’s arguments to keep family detention centers active, citing the 1997 Flores settlement.

The Flores settlement “unambiguously applies both to minors who are accompanied and unaccompanied by their parents,” according to a 2016 ruling by the Ninth Circuit of Appeals.

Back in 2015, two new family detention centers were built or in the process of being built to expand the government’s detention capacity to house 3,400 immigrant women and children fleeing from drug-infested countries such as Guatemala, Honduras and El Salvador. Judge Gee ordered that the families that did not pose the risk of evading law enforcement officials be released.

Get our Politics Newsletter. The headlines out of Washington never seem to slow. Subscribe to The D.C. Brief to make sense of what matters most. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Write to Abby Vesoulis at abby.vesoulis@time.com.