WASHINGTON — President Donald Trump told House Republicans Tuesday night that he is "1,000 percent" with them as GOP leaders try to pass a sprawling immigration bill, and that he wants to see an end to his policy of separating undocumented children from their parents at the U.S.-Mexico border.

"We gotta take care of separation," Trump said, according to people who were in the closed-door meeting in the basement of the Capitol. "It's too nasty."

Trump, who wants to change the policy with legislation rather than reversing it unilaterally, did not take questions from House Republicans.

Technically, the president gave his endorsement to two bills — one by House Judiciary Chairman Bob Goodlatte, R-Va., that is popular with immigration hard-liners and a second "compromise" measure that reflects a deal between GOP conservatives and moderates — both of which House leaders are likely to put on the floor later this week.

"In his remarks, he endorsed both House immigration bills that build the wall, close legal loopholes, cancel the visa lottery, curb chain migration, and solve the border crisis and family separation issue by allowing for family detention and removal," White House deputy press secretary Raj Shah said in a statement.

But because the Goodlatte measure is less likely to pass, and because he spoke in favor of elements that are in the other version, many lawmakers read the president's remarks as support for the compromise bill.

He was "as strong as garlic" in his backing of the compromise bill, said Rep. Kevin Brady, R-Texas.

Asked if Trump had specifically endorsed the compromise bill, House Majority Whip Steve Scalise, R-La., recalled Trump saying, "We need this approved."

The compromise bill would provide nearly $25 billion in funding for Trump's border wall, limit legal and illegal immigration, provide protection from deportation and a path to citizenship for recipients of President Barack Obama's Deferred Action for Childhood Arrivals program, and reverse Trump's "zero tolerance" policy, which results in undocumented families' being detained in separate facilities.

Republicans said they still have a lot of work to do to secure votes for that plan, which some conservatives describe as "amnesty" because it would allow certain undocumented immigrants to eventually become citizens.

Trump took on that issue squarely in the meeting, contending that the burden for getting citizenship would be significant and that it would be linked to the construction of the border wall.

"You have to work, work, work ... then after 10, 12, maybe 13 years you have a chance to become a citizen," Trump said. "There is no one in the room more hard-line on immigration than me, but this gives people an incentive, otherwise there is no incentive. This is a tremendous incentive. So you're talking 12, 13 years out and then you don't even get a green card until the wall is built so this is an incentive to get the wall built faster. People are gonna want us to build the wall. So that plus border security."

Some Republicans credited the president with laying the groundwork to pick up new votes from GOP lawmakers wary of angering their constituents.

"For him to say he's a thousand percent behind it, that means a lot to our members who need the political cover, if you will, on a tough vote," said Rep. Michael McCaul, R-Texas, who has endorsed both bills.

Trump arrived on Capitol Hill Tuesday amid deep consternation among Republicans over his "zero tolerance" policy. That's addressed in the House bills, but it's not clear that either of them could pass the House or the Senate. The vast majority of Democrats are opposed to the House bills.

In fact, many Republicans on both sides of the Capitol were pushing back on his policy before his remarks.

"I support, and all of the Republican conference support, a plan that keeps families together while their immigration status is determined," said Senate Majority Leader Mitch McConnell, R-Ky.

Trump himself remained focused on the big picture. "The system has been broke for many years," the president told reporters as he arrived on Capitol Hill. "It's been a really bad, bad system, probably the worst anywhere in the world. We're going to try and see if we can fix it."

But it was the separation policy — which could be changed by Trump himself or by legislative action — that had roiled the debate over his priorities, turned House Republicans into critics and pushed Senate Republican leaders into open rebellion.

Rather than solving the separation issue as part of a catchall immigration bill — which would have difficulty garnering 60 Senate votes — Senate leaders suggested Tuesday that they wanted to do it in a narrower standalone measure.

"Hopefully we'll get this problem addressed right away," said Senate Majority Whip John Cornyn, R-Texas. "My hope is this is not going to be something that we're going to do over a matter of weeks or months but something we could do in a matter of days, hopefully this week."

That was a direct challenge to Trump and White House aides, for whom the crisis over family separation is an opportunity to score victories on the rest of his immigration plan. However, there were several ideas floating around in the Senate — from Sen. Ted Cruz's plan to create facilities for families and increase the number of immigration judges, to Sen. Dianne Feinstein's proposal to simply end the Trump policy — and there's no consensus yet in the Senate as to which, if any, could garner the votes necessary for passage.

Senate Judiciary Committee Chairman Charles Grassley, R-Iowa, is introducing a bill that would overturn the "Flores consent decree," which requires the federal government to release undocumented minors after 20 days, according to a federal court ruling.

The pushback from Senate GOP leaders reflected the nervousness congressional Republicans were feeling over the political heat they've been taking on the zero-tolerance policy.

Nearly three dozen House Republicans, including several of the most politically vulnerable lawmakers in the country, have said they oppose the separation policy.

The chairman of the National Republican Congressional Committee, the arm of the party responsible for keeping Republican incumbents in office, said he couldn't abide it.

"As a father, I know firsthand that there is nothing more important than family, and I understand why kids need to be with their parents," said Rep. Steve Stivers, R-Ohio. "That’s why I have publicly come out against separating children from their parents at the border."

And Rep. Mike Coffman, R-Colo., who sits in one of the nation's toughest districts, said Monday that he supports Feinstein's measure.

The crux is that Trump's policy designs are running smack into the electoral needs of congressional Republicans, who are trying to maintain their majorities in the Senate and the House, said Michael Caputo, who advised Trump during the 2016 campaign and remains a staunch ally of the president.

"For Donald Trump, this isn’t a popularity contest. He wants to get some things done that aren’t particularly popular," Caputo said. "And for congressmen up for re-election in 2018 it’s absolutely a popularity contest. The tension between those two perspectives is on display."

It doesn't take a political scientist to read the current public mood on the topic: A Quinnipiac poll released Monday showed that two-thirds of Americans oppose the separation policy. While 55 percent of Republicans support it, that's a much smaller figure than the share of Republicans who generally approve of the job Trump is doing — which is 90 percent in the latest Gallup poll.

Trump has blamed Democrats for the impasse over border policy, even though officials in his administration boasted about its implementation and have said it was designed to act as a deterrent to parents who are thinking about bringing their children to the U.S. illegally.

"We need Democrats' support. They don’t want to give it because Democrats love open borders," he said. He also falsely accused them of wanting to "infest" the country with undocumented immigrants, including members of the gang MS-13.

Republican leaders have been trying to pass immigration legislation without input from Democrats, and GOP lawmakers and aides said they would like to see him make more of a public push for the compromise bill now that he's endorsed it behind closed doors.

But Trump has been a difficult partner at times.

He created chaos and confusion for hours on Friday after saying that he wouldn't sign the compromise immigration bill — which reflects an agreement between conservatives and moderates in GOP ranks but not Democrats — even though it included all of the items he'd demanded.

And just hours before he was set to address them, Trump said he would ask Republicans for changes to their legislation.

"We have one chance to get it right, or let's just keep going," Trump said earlier Tuesday.

But by Tuesday night, he had moved from the negotiating phase to sell mode.

"We are going to get this done," Trump said, according to a person in the room. "I’m with you. I love you people."