In a sudden reversal, President Trump on Wednesday signed an executive order designed to keep together immigrant families who have been detained at the U.S.-Mexico border, while also retaining his administration’s so-called “zero-tolerance” immigration policy.

“I didn’t like the sight or the feeling of families being separated,” Trump said from the Oval Office. “At the same time, we are keeping a very powerful border, but continue to be zero tolerance.”

Trump’s executive order would keep most families together under the Department of Homeland Security, except in cases where an adult may pose a threat to a child. (Read the full executive order and an explanation of it here.) “You’re going to have a lot of happy people,” Trump said as he signed the order.

While the order could possibly work to quell the furor over the controversial practice of separating families at the border, it marks a reversal for a man who hates to admit defeat, and comes just days after arguments from his administration that only lawmakers could put an end to the practice. “Congress and the courts created this problem, and Congress alone can fix it,” Homeland Security Secretary Kirstjen Nielsen said Monday. Nielsen appeared alongside Trump Wednesday as he signed the order meant to end family separations.

Vice President Mike Pence, who also appeared with Trump at the signing, said that the order would enable families to stay together in the immediate future, but added that it was still up to Congress to come up with a permanent solution, presumably as part of a larger immigration package. The House is slated to vote Thursday on two immigration bills, one of which appears doomed while the other has only a moderate prospect of passing. Lawmakers in general are not remotely close to a consensus on what an immigration solution might actually look like.

The order is virtually certain to encounter legal challenges. Some advocates will likely argue that children staying in detention centers violates the 1997 decision known as the Flores agreement. Although the Executive Order mandates that Attorney General Jeff Sessions request a U.S. district court to modify the agreement, Trump acknowledged he could be headed for a fight. “There may be some litigation,” he conceded.

The separations at the border began earlier this year, when Sessions mandated that all people caught crossing into the U.S. illegally be referred for criminal prosecution. Under that policy, adults were sent to jail under the auspices of the Department of Homeland Security, while children have been held in facilities run by the Office of Refugee Resettlement. Since the policy was implemented, over 2,000 children have been separated, according to government figures.

The backlash, spurred by images of children crying, audio documenting the separation, and personal accounts from those experiencing it, was swift and intense, and came from both sides of the aisle. Former First Lady Laura Bush called it “cruel” and “immoral,” Pope Francis said populists’ immigration policies were “creating psychosis,” and Senator John McCain called it an “affront to American decency.”

But until Wednesday, Trump had been vociferously defending his immigration policy. He insisted Tuesday that illegal immigrants were “infesting” the country, and subsequently asserted that the only other option was to release all the undocumented immigrants detained at the border.

However, Trump insisted Wednesday that his executive order was not a sign of his backing down. “The border’s just as tough,” he told reporters. “They can come in through ports of entry if they want. That’s a whole different story. And that’s coming in through a process, and the process is what we want.”

–With reporting by Philip Elliott/Washington

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 Alana Abramson at Alana.Abramson@time.com.