“Certain Washington politicians choose to fight for foreign countries, but President Trump will always fight for the American people,” Mr. Shah said. “Like other nations that have merit-based immigration, President Trump is fighting for permanent solutions that make our country stronger by welcoming those who can contribute to our society, grow our economy and assimilate into our great nation.”
But the president’s vulgar language on a delicate issue left the fate of the broader immigration debate in limbo and had the potential to torpedo the chances of achieving the deal being sought to protect about 800,000 undocumented immigrants brought to the country as children. And they drew a backlash from Republican and Democratic lawmakers, many of whom called Mr. Trump’s utterances unacceptable at best and plainly racist at worst.
Representative Mia Love, a Republican of Utah who is of Haitian descent, demanded an apology from the president, saying his comments were “unkind, divisive, elitist, and fly in the face of our nation’s values.”
“This behavior is unacceptable from the leader of our nation,” Ms. Love went on in an emotional statement that noted her heritage and that said her parents “never took a thing” from the government while achieving the American dream. “The president must apologize to both the American people and the nations he so wantonly maligned.”
“As an American, I am ashamed of the president,” said Representative Luis V. Gutiérrez, Democrat of Illinois. “His comments are disappointing, unbelievable, but not surprising.” He added, we can now “say with 100 percent confidence that the president is a racist who does not share the values enshrined in our Constitution or Declaration of Independence.”
The reactions were extraordinary bipartisan rebukes to a sitting president, but they only fanned what has been a long-simmering debate over Mr. Trump’s views and talk on race.
Mr. Trump sought to have the final word late Thursday, posting on Twitter shortly before midnight: “The Democrats seem intent on having people and drugs pour into our country from the Southern Border, risking thousands of lives in the process. It is my duty to protect the lives and safety of all Americans. We must build a Great Wall, think Merit and end Lottery & Chain. USA!”
As a candidate, Mr. Trump, who rose to political prominence questioning the validity of President Barack Obama’s birth certificate, branded Mexican immigrants rapists and criminals, called for a ban on Muslims entering the United States and was slow to disavow the support of the former Ku Klux Klan leader David Duke.
As the president, Mr. Trump has ordered a broad immigration crackdown while privately railing against immigrants from predominantly black countries and has repeatedly stoked racial divisions, denouncing “both sides” for violence after a white supremacist rally in Charlottesville, Va., and singling out black athletes for failing to stand for the national anthem before their games.
The episode at the White House, first reported by The Washington Post, unfolded as Mr. Trump was hosting a meeting with Senator Lindsey Graham, Republican of South Carolina, and Richard J. Durbin, Democrat of Illinois, who are working to codify the protections in the Deferred Action for Childhood Arrivals program, or DACA, the Obama-era initiative that provided temporary work permits and reprieves from deportation to immigrants brought to the United States as children by their parents.
Also present were Representative Kevin McCarthy, Republican of California and the majority leader; Senator David Perdue, Republican of Georgia; Senator Tom Cotton, Republican of Arkansas; and Representative Robert W. Goodlatte, Republican of Virginia and the chairman of the Judiciary Committee.
None of the lawmakers would comment on Mr. Trump’s remarks.
The plan outlined by Mr. Graham and Mr. Durbin, according to people familiar with it, would also include more than $2.5 billion for border security and a grant of protected status for the parents of the immigrants, known as Dreamers, who would be barred from sponsoring their parents for citizenship.
Mr. Trump grew angry as the group detailed another aspect of the deal — a move to end the diversity visa lottery program and use some of the 50,000 visas that are annually distributed as part of the program to protect vulnerable populations who have been living in the United States under what is known as Temporary Protected Status. That was when Mr. Durbin mentioned Haiti, prompting the president’s criticism.
When the discussion turned to African nations, those with knowledge of the conversation added, Mr. Trump asked why he would want “all these people from shithole countries,” adding that the United States should admit more people from places like Norway.
About 83 percent of Norway’s population is ethnic Norwegian, according to a 2017 C.I.A. fact book, making the country overwhelmingly white.
Mr. Trump has long argued that the United States should base legal immigration on merit and skills rather than family ties, seeking new entrants who are highly educated, capable of assimilating and unlikely to use government programs for the poor. Some people familiar with his comments argued privately on Thursday night that the president had only tried to press that point, using salty language.
But it was the language he used that shocked and appalled many lawmakers and created a public outcry — the vulgar phrase Mr. Trump uttered quickly began trending on Twitter — overshadowing the substance of the DACA talks, and with it, the future of the immigrants at risk of deportation should those discussions fail.
Representative Cedric L. Richmond, Democrat of Louisiana and the chairman of the Congressional Black Caucus, called the president’s closed-door comments “yet another confirmation of his racially insensitive and ignorant views” and said they reinforced “the concerns that we hear every day, that the president’s slogan, ‘Make America Great Again,’ is really code for ‘Make America White Again.’”