Aside from serving as a vehicle for two populist leaders to voice their immigration concerns, the news conference was the first time Mr. Trump had taken questions from journalists since a taped conversation surfaced between him and Michael D. Cohen, his longtime lawyer, in which they discussed payments to a former Playboy model who said she had an affair with Mr. Trump. The conversation, taped weeks before the 2016 election, showed that Mr. Trump knew about the payments, a fact that his campaign had denied.

His comments on immigration did not find a welcome reception on Capitol Hill, where Republicans staring toward November’s elections were quick to distance themselves. The party risks losing control of one or both chambers, and its leaders have made abundantly clear they see no upside to a messy government shutdown in the weeks before voters cast their ballots.

“Obviously up here, we want to keep the government up and functioning,” said Senator John Thune of South Dakota, the No. 3 Senate Republican. “I’m not sure where the president is coming from.”

Senator Orrin G. Hatch of Utah, the longest serving Republican in the Senate, chalked the comments up to a negotiating technique — though perhaps an ill-advised one.

“He knows the game,” Mr. Hatch said. “But we don’t want to do that again. Nobody wants that.”

Republican leaders in both chambers expect to pass the majority of the 12 appropriations bills necessary to keep the government operating before Sept. 30, the end of the fiscal year. Between those bills and a short-term spending measure to bridge the gap, they believe they can push off any potential fights — including over border wall funding — until later in the fall.