WASHINGTON — President Trump on Thursday balked at an immigration deal that would include protections for people from Haiti and some nations in Africa, demanding to know at a White House meeting why he should accept immigrants from “shithole countries” rather than from places like Norway, according to people with direct knowledge of the conversation.

Mr. Trump’s remarks, the latest example of his penchant for racially tinged remarks denigrating immigrants, left members of Congress from both parties attending the meeting in the Oval Office alarmed and mystified. He made them during a discussion of an emerging bipartisan deal to give legal status to immigrants illegally brought to the United States as children, those with knowledge of the conversation said, speaking on the condition of anonymity to discuss the meeting.

When Mr. Trump heard that Haitians were among those who would benefit from the proposed deal, he asked whether they could be left out of the plan, asking, “Why do we want people from Haiti here?”

The comments were reminiscent of ones the president made last year in an Oval Office meeting with cabinet officials and administration aides, during which he complained about admitting Haitians to the country, saying that they all had AIDS, as well as Nigerians, who he said would never go back to their “huts,” according to officials who heard the statements in person or were briefed on the remarks by people who had. The White House vehemently denied last month that Mr. Trump made those remarks.