WASHINGTON — After days of outcry, President Donald Trump is backing off of a contentious new policy that separated more than 2,300 immigrant children from their parents who crossed the border illegally.

And, it seems, he has the Republican-dominated Congress behind him: On Wednesday afternoon, as the president signed an executive order halting those separations, top Senate Republicans introduced a bill that would achieve much the same goals.

Both the order and the legislation are designed to address the consequences of Trump’s policy of criminally prosecuting everyone who crosses the border illegally without relaxing the policy itself. Under the administration’s “zero tolerance” policy, when parents cross the border illegally, their children are taken from them because they cannot be sent to jails. The order directs that “to the extent permitted by law,” immigrant families should be held together in immigration detention facilities run by the Department of Homeland Security.

“We’re going to have strong, very strong borders, but we’re going to keep the families together,” Trump said.

Meanwhile, a government offiical told The New York Times that the children who have already been separated from their parents won't be immediately reunited.

The decision to keep children — some reportedly as young as 8 months old — away from their parents and under the care of strangers has drawn strong rebukes from lawmakers, religious leaders and immigration advocates across the country. Even before Trump's announcement, lawmakers were working on bills to end the separations.

On Wednesday, Senate Republicans — including both U.S. senators from Texas — introduced the Keep Families Together and Enforce the Law Act, which would hold families together in detention centers run by the Department of Homeland Security as they await a court hearing. That would effectively give the administration the best of both worlds: a strict immigration process without the family separations that have earned near-universal backlash.

“A zero tolerance policy is exactly correct, I think a family reunification policy is exactly correct,” U.S. Sen. John Cornyn told reporters Wednesday.

The executive and legislative measures are geared toward the same goal. But, Cornyn said, congressional action is necessary because “there probably will be legal challenges to the president’s executive order.”

“It’s important to have the backstop of congressional action to be able to preserve this family unity goal,” said Cornyn, who is among the most powerful Republicans in Congress.

The executive order seems to put Trump squarely at odds with a 1997 legal constraint known as the Flores settlement, which says children may not be detained for more than 20 days, even if they are with their parents. That had kept President Barack Obama from keeping families together in detention centers during a similar immigration surge.

In the order, Trump directs Attorney General Jeff Sessions to work to “modify” that settlement agreement to permit the government “to detain alien families together throughout the pendency of criminal proceedings for improper entry or any removal or other immigration proceedings.”

The executive order also represents a sharp departure from the administration’s previous position, a reversal that seems to have been prompted by a flood of public outcry over the last several days.

Facing widespread, harsh criticism from both sides of the aisle and all corners of the country, Trump at first defended the policy by saying he was simply following the law and insisted, incorrectly, that only Congress could stop the separations.

Under past administrations, most first-time border crossers had not been criminally prosecuted for illegally entering the country.

Even in Texas, where prominent Republicans tend to hew to the Trump line, many statewide Republican leaders, including Gov. Greg Abbott and both of the state's U.S. senators, had been calling for ending the separations. Members of the Texas congressional delegation on both sides of the aisle praised Trump’s order, voicing relief that the humanitarian and public relations disaster would now come to an end.

“He did the right thing. I’m glad he did it,” said U.S. Rep. Ted Poe, R-Houston.

As he walked into a vote Wednesday afternoon, U.S. Rep. Henry Cuellar, D-Laredo, shouted over his shoulder, “It’s about time.”

Democrats were reluctant, though, to give credit to Trump for ending a problem he started in the first place.

“This was a problem that he alone created,” said U.S. Rep. Joaquin Castro, D-San Antonio.

And representatives were divided over whether Congress needs to codify measures to keep immigrant families together.

“It’d be nice to codify his actions, but it’s not absolutely essential,” said U.S. Rep. Lamar Smith, R-San Antonio. “This probably solves the problem.”

Cuellar agreed. But a number of Texas lawmakers emphasized the unpredictable nature of executive orders — and argued that Congress must pass legislation to ensure families are not subject to the whim of a president’s pen.

“It’s an executive order, and we all know executive orders can be changed by whoever comes around, comes to office later,” Poe said. “But this is Congress’ responsibility, and Congress must weigh in on this issue, as well as border security and immigration.”

Abby Livingston contributed reporting from Washington.