"Judging from how this went, I have some optimism that this could actually get done. It will be difficult," Curbelo said Tuesday evening as House Republican leaders were set to gauge support for the immigration bills.

The president told the GOP caucus that he supports its efforts to pass either of the two immigration bills the House will consider this week, Republican lawmakers said to reporters following the meeting. Trump signaled he would support a measure crafted as a compromise between centrist and conservative Republicans without explicitly endorsing the legislation, according to Reps. Ryan Costello, R-Pa., and Carlos Curbelo, R-Fla.

But he reportedly spent much of his time during Capitol Hill remarks ostensibly about immigration policy riffing on topics such as trade, the Russia investigation and the primary election defeat of incumbent GOP Rep. Mark Sanford.

President Donald Trump urged House Republicans to pass an immigration bill Tuesday as an uproar over his policy of separating migrant children from parents engulfs his administration.

Trump's visit to the Capitol came during one of the most politically fraught moments of his presidency, as he faces bipartisan backlash over his administration's decision to split up families crossing U.S. borders illegally. Even as lawmakers rightfully note he could end the policy today, the president has pushed for Congress to pass a bill that would end the practice while also enacting his strict border security proposals. Trump has shown no willingness to stop the practice himself.

The GOP compromise bill officially unveiled Tuesday would fund Trump's proposed border wall, create a pathway to citizenship for young immigrants brought to the U.S. illegally as children, end the diversity visa "lottery" program in favor of what the GOP calls a merit-based visa pool and seek to end the separation of migrant children and parents. Following the meeting, the White House said Trump supports the legislation.

He told members that "I'm with you 100 percent," according to deputy press secretary Raj Shah. On Friday, Trump created confusion by saying he would not back the "more moderate" immigration measure. Shah walked back the president's statement hours later.

Still, it is unclear whether the bill can win enough support to pass the House, and it faces a tough path to getting through the Senate. Some of the GOP's rightmost flank has objected to offering a path to citizenship for the young immigrants. Rep. Mark Meadows, a North Carolina Republican who chairs the conservative House Freedom Caucus, would not say Tuesday evening whether his group would support the bill, according to NBC News.

Costello told reporters that Trump's support "should be helpful" to Republicans' effort to pass the bill.

Immigration dominated Trump's day: He spent much of an afternoon speech to a small business association riffing about immigration and suggesting he could push for changes to the House GOP legislation. He apparently did not mention changes Tuesday evening. Leaving the meeting in the Capitol, he faced sign-wielding House Democrats who yelled and chanted in urging the president to end the family separation policy himself.

Tweet: A group of House Democrats with signs reading "Families belong together" confronted Pres. Trump as he left the U.S. Capitol after meeting with House Republicans. "We won't go away!" Rep. Adriano Espaillat shouted at the president.

Though immigration was top of mind for lawmakers, Trump reportedly strayed from the topic early and often during his remarks to Republicans. Curbelo noted that Trump's comments "did wander a bit."

Trump made the room fall silent when he mockingly said he wanted to "congratulate" Sanford on his primary race, according to Politico. The South Carolina Republican, an occasional Trump critic, lost a primary this month to a challenger who criticized him for not doing enough to help the president.

The president called Sanford "nasty," the news outlet reported. The representative was not in the room.

For his part, Sanford told Charleston's The Post and Courier that Trump's decision to "shoot at a guy you've already shot and killed, is perplexing and unfortunate." The politician told the newspaper he never meant for his policy disagreements with Trump to be regarded as personal insults, but "somehow he takes it personally and responds personally."

Trump also told Republicans not to worry about escalating tensions with major trade partners such as China, according to Politico. A series of tariffs, threats and retaliatory broadsides between Washington and Beijing have raised fears about damage to the world's two largest economies and contributed to stock markets broadly falling this week.

Trump told Republicans that trade isn't "tricky," according to the news outlet.

Aside from those topics, Trump touched on the Republican tax law, the probe into Russia's efforts to influence the 2016 election and his push to get North Korea to give up its nuclear ambitions, according to reports.