“It’s not going to change a damn thing, but I’m still doing it,” Mr. Trump said of the border visit, according to one of the people, who was in the room. The trip was merely a photo opportunity, he said. “But,” he added, gesturing at his communications aides Bill Shine, Sarah Huckabee Sanders and Kellyanne Conway, “these people behind you say it’s worth it.”

Mr. Trump plans to head to the Capitol on Wednesday to attend a Senate Republican lunch and later will host congressional leaders from both parties to resume negotiations that so far have made little progress. Mr. Trump has insisted on $5.7 billion for the wall, while Ms. Pelosi said she would not give him a dollar for a wall she has called “immoral.”

In a nod to Democrats, Mr. Trump spent the first half of his talk on the humanitarian situation at the border before even mentioning the wall, expressing sympathy for those victimized by human smugglers. “This is a humanitarian crisis — a crisis of the heart and a crisis of the soul,” he said.

Even so, he directly took on Ms. Pelosi and Mr. Schumer. “The only thing that is immoral is the politicians to do nothing and continue to allow more innocent people to be so horribly victimized,” he said.

Mr. Trump has made the wall the singular focus of his presidency as he enters his third year in office. His promise to erect a “big, beautiful wall” along the border became perhaps the most memorable promise on the campaign trail this fall, eliciting chants from supporters of “build the wall,” and he has been frustrated by his inability to deliver on it.

But his alarming description of a “crisis” at the border has raised credibility questions. While experts agree there are serious problems to address, migrant border crossings have actually been declining for nearly two decades. The majority of heroin enters the United States through legal ports of entry, not through open areas of the border. And the State Department said in a recent report that there was “no credible evidence” that terrorist groups had sent operatives to enter the United States through Mexico.