The White House said Friday that President Trump supports House legislation that closely tracks his priorities on border security and limiting legal immigration, walking back comments he made on national television rejecting the GOP bill.

The reversal came after hours of confusion on Capitol Hill, where Trump’s words roiled an already fragile internal debate between conservative and moderate House Republicans who have been trying to find an immigration compromise after months of false starts.

“The president fully supports both the Goodlatte bill and the House leadership bill,” White House spokesman Raj Shah said, referring to legislation drafted by House Judiciary Committee Chairman Bob Goodlatte (R-Va.) and a separate compromise measure. 

Shah said Trump, during his “Fox and Friends” interview, was referring to an effort led by moderate House Republicans to force a series of immigration votes over the objections of the GOP leadership. Another senior White House official said Trump misunderstood the question that was posed to him, which prompted the president to say that he “certainly wouldn’t sign the more moderate one.”

House Republican leaders had teed up action on two immigration measures: a hard-line draft written by Goodlatte and legislation billed as a compromise between the moderate and conservative factions of the GOP conference.

The draft compromise bill released Thursday was written with White House input, including from top Trump immigration adviser Stephen Miller, and closely hews to the “four pillars” the administration set out in a January framework.

Among those pillars are guaranteed funding of $25 billion for a physical wall along the Mexican border; ending the Diversity Visa Program that currently offers admission by lottery to 55,000 immigrants each year; and an end to the system of family-based immigration that distributes visas to the spouses, children and siblings of U.S. citizens. In return, Trump offered a path to citizenship for roughly 1.8 million “dreamers” who came illegally to the U.S. as children.

The draft bill ends the Diversity Visa Program and scales back family-based immigration visas, while offering a path to citizenship to dreamers that is contingent on the provision of border wall funding.

As late as Thursday night, White House officials were closely coordinating with House Republican leaders over the bill, with the understanding that Trump would endorse it and ultimately sign it if passed. 

The administration even drafted and circulated a Statement of Administration Policy — an official White House position on the bill — indicating that Trump’s advisers “would recommend that he sign it into law.”

“The Border Security and Immigration Reform Act of 2018 would support the administration’s goals of securing the border, closing legal loopholes, moving to a system of merit-based immigration, and protecting those who were illegally brought to the United States as children,” said a draft statement obtained by The Washington Post. 

Then, after Trump made his remarks Friday morning, House Republicans scrambled to determine whether he had had a change of heart.

“House Republicans are not going to take on immigration without the support and endorsement of President Trump,” said Rep. Patrick T. McHenry (R-N.C.), the Republican chief deputy whip, who said the leadership would delay gauging support for the bill while seeking an explanation from the White House.

In a tweet Friday afternoon, Trump listed his priorities on immigration that hewed closely to the framework of the compromise bill, while never explicitly reversed his opposition.

“The Democrats are forcing the breakup of families at the Border with their horrible and cruel legislative agenda. Any Immigration Bill MUST HAVE full funding for the Wall, end Catch & Release, Visa Lottery and Chain, and go to Merit Based Immigration. Go for it! WIN!” the president tweeted.

House Speaker Paul D. Ryan (R-Wis.) had told his members earlier this week that he had briefed Trump on the legislative strategy and that the president was on board.

Shortly after Trump’s “Fox and Friends” comments, Rep. Jim Jordan (R-Ohio) — an influential leader of the conference’s conservative wing — said he would not support a more moderate immigration bill that the president would not sign.

“Maybe now we’ll get enough votes for the Goodlatte bill,” Jordan said, noting that “a lot” of conservatives already had concerns about the compromise legislation before Trump weighed in. “That’d be great.”  

The measure would also end the Trump administration’s practice of separating immigrant children from their families when they are apprehended at the border by effectively allowing children to be detained with their parents.

A new Trump administration policy that refers everyone who has crossed the border illegally for prosecution has forced the separation of many migrant families, since children can’t be detained in criminal jails alongside their parents. 

The proposed changes in the House GOP bill would override a 1997 settlement — which calls on migrant children to be held in the least restrictive setting possible — and related litigation to make clear there is “no presumption that an alien child should not be detained” and that those children must not “be released by the Secretary of Homeland Security other than to a parent or legal guardian.”

Trump continued to falsely assert Friday that separating migrant families was a law spearheaded by Democrats. A 2008 anti-trafficking law that requires unaccompanied migrant children to be sent into the care of Health and Human Services — another statute blamed by the administration for the family separation — was passed unanimously by Congress and signed into law by then-President George W. Bush, a Republican.

“I hate the children being taken away,” Trump said Friday morning.

House Democrats are expected to oppose the GOP compromise bill. House Minority Whip Steny H. Hoyer (D-Md.) said Friday that the measure is “very, very bad, but apparently not bad enough for President Trump.” 

“Where are the Republicans? Where are my colleagues on the other side of the aisle who are willing to stand up to their president?” said Rep. Luis V. Gutiérrez (D-Ill.), one of Capitol Hill’s most vocal immigration advocates. Gutiérrez added that Republican lawmakers are “scared of the president’s itchy Twitter finger.”

Democrats are now urging moderate Republicans to vote against a procedural move next week to bring the conservative Goodlatte measure to the floor for a vote. Doing so would keep a discharge petition — brought forward by moderate Republicans to force a series of immigration votes — alive. That petition is just two signatures short of succeeding.

The moderate Republicans who prompted the immigration fight were scrambling Friday to determine whether Trump really meant what he said during his “Fox and Friends” interview.

“I’m not sure that the president understood the question, so we’re checking to see if he did,” said Rep. John Katko (R-N.Y.), a moderate who participated in the talks. “I still have faith that when he sees the bill and has a chance to digest it, he’ll support it.” 

Josh Dawsey and John Wagner contributed to this report.