President Trump abruptly reversed course Wednesday, saying he would sign an executive order ending family separations at the U.S.-Mexico border after a public uproar over his administration's "zero tolerance" immigration policy.

The plan, as described by administration officials, would keep families together in federal custody while awaiting prosecution for illegal border crossings, potentially violating a 1997 court settlement limiting the duration of child detentions.

"We have to be very strong on the border but at the same time we want to be very compassionate," Trump said at the White House during a meeting with lawmakers that was opened to the media.

Trump had repeatedly defended his immigration crackdown, including forcibly separating migrant children from their parents after they crossed the border. But images of young children in tears, housed in metal cages, set off an international outcry.

For days, Trump and his top administration officials were unwilling to unilaterally reverse the separation policy and insisted that congressional action was required.

The inaction sparked international outrage, including criticism from Pope Francis and opposition from world leaders.

Trump's remarks came shortly after House Republican leaders vowed to bring broader immigration legislation up for votes Thursday to address the crisis, despite widespread skepticism that a bill could pass.

"I'll be doing something that's somewhat preemptive and ultimately will be matched by legislation, I'm sure," Trump said at the White House, adding that he would still like to see Congress take action later.

One administration official said Trump's order would end separations by keeping families together in immigration detention centers.

U.S. Immigration and Customs Enforcement (ICE) operates two large detention centers for families in Texas and a smaller one in Pennsylvania, but their combined capacity is about 3,000 beds.

As of mid-June, the three centers were nearly full, meaning ICE would potentially need to place children in its much larger network of immigration jails for adults.

That would most likely violate the 1997 "Flores Settlement" agreement that limits the government's ability to keep children in detention and orders them to be placed in least-restrictive setting possible.

A subsequent ruling in 2016 bars the government from keeping children in family detention centers for more than 20 days.

An administration official with knowledge of the plan indicated that the Trump administration was anticipating lawsuits and preparing to litigate Flores in court, particularly if lawmakers fail to approve a legislative fix.

"It may be easier to overturn the Flores Settlement than get Congress to pass something," said Mark Krikorian, director of the Center for Immigration Studies, a Washington think tank whose restrictionist views on immigration policy have won broad influence in the White House.

"Getting rid of the Flores Settlement is the quickest way to solve the problem," Krikorian said. "The government has been faced with the choice of either splitting the family by detaining the parent and releasing the kid, or just letting the parent go too."

Striking down the ruling became a goal of immigration hard-liners, particularly after the 2016 ruling by the 9th Circuit Court of Appeals limiting the government's ability to keep children in detention for more than 20 days.

In most cases, that window is not enough time for those families to go before an immigration judge, so ICE has typically released families together with some form of electronic monitoring.

The Trump administration's "zero tolerance" policy broke with that approach by separating families and sending adults into ICE jails whike assigning migrant children to shelters run by the Department of Health and Human Services.

Trump's executive order would instead keep entire families in ICE detention centers, likely in violation of the 9th Circuit Court's ruling on the Flores Settlement.

Seung Min Kim contributed to this report.