But so many foreigners had flooded into the country since January, he vented to his national security team, that it was making a mockery of his pledge. Friends were calling to say he looked like a fool, Mr. Trump said.

According to six officials who attended or were briefed about the meeting, Mr. Trump then began reading aloud from the document, which his domestic policy adviser, Stephen Miller, had given him just before the meeting. The document listed how many immigrants had received visas to enter the United States in 2017.

More than 2,500 were from Afghanistan, a terrorist haven, the president complained.

Haiti had sent 15,000 people. They “all have AIDS,” he grumbled, according to one person who attended the meeting and another person who was briefed about it by a different person who was there.

Forty thousand had come from Nigeria, Mr. Trump added. Once they had seen the United States, they would never “go back to their huts” in Africa, recalled the two officials, who asked for anonymity to discuss a sensitive conversation in the Oval Office.

As the meeting continued, John F. Kelly, then the secretary of homeland security, and Rex W. Tillerson, the secretary of state, tried to interject, explaining that many were short-term travelers making one-time visits. But as the president continued, Mr. Kelly and Mr. Miller turned their ire on Mr. Tillerson, blaming him for the influx of foreigners and prompting the secretary of state to throw up his arms in frustration. If he was so bad at his job, maybe he should stop issuing visas altogether, Mr. Tillerson fired back.

Tempers flared and Mr. Kelly asked that the room be cleared of staff members. But even after the door to the Oval Office was closed, aides could still hear the president berating his most senior advisers.

Sarah Huckabee Sanders, the White House press secretary, denied on Saturday morning that Mr. Trump had made derogatory statements about immigrants during the meeting.

“General Kelly, General McMaster, Secretary Tillerson, Secretary Nielsen and all other senior staff actually in the meeting deny these outrageous claims,” she said, referring to the current White House chief of staff, the national security adviser and the secretaries of state and homeland security. “It’s both sad and telling The New York Times would print the lies of their anonymous ‘sources’ anyway.”

While the White House did not deny the overall description of the meeting, officials strenuously insisted that Mr. Trump never used the words “AIDS” or “huts” to describe people from any country. Several participants in the meeting told Times reporters that they did not recall the president using those words and did not think he had, but the two officials who described the comments found them so noteworthy that they related them to others at the time.

The meeting in June reflects Mr. Trump’s visceral approach to an issue that defined his campaign and has indelibly shaped the first year of his presidency.

Seizing on immigration as the cause of countless social and economic problems, Mr. Trump entered office with an agenda of symbolic but incompletely thought-out goals, the product not of rigorous policy debate but of emotionally charged personal interactions and an instinct for tapping into the nativist views of white working-class Americans.

Like many of his initiatives, his effort to change American immigration policy has been executed through a disorderly and dysfunctional process that sought from the start to defy the bureaucracy charged with enforcing it, according to interviews with three dozen current and former administration officials, lawmakers and others close to the process, many of whom spoke on the condition of anonymity to detail private interactions.

But while Mr. Trump has been repeatedly frustrated by the limits of his power, his efforts to remake decades of immigration policy have gained increasing momentum as the White House became more disciplined and adept at either ignoring or undercutting the entrenched opposition of many parts of the government. The resulting changes have had far-reaching consequences, not only for the immigrants who have sought to make a new home in this country, but also for the United States’ image in the world.

“We have taken a giant steamliner barreling full speed,” Mr. Miller said in a recent interview. “Slowed it, stopped it, begun to turn it around and started sailing in the other direction.”

It is an assessment shared ruefully by Mr. Trump’s harshest critics, who see a darker view of the past year. Frank Sharry, the executive director of America’s Voice, a pro-immigration group, argues that the president’s immigration agenda is motivated by racism.

“He’s basically saying, ‘You people of color coming to America seeking the American dream are a threat to the white people,’” said Mr. Sharry, an outspoken critic of the president. “He’s come into office with an aggressive strategy of trying to reverse the demographic changes underway in America.”

Image

Mr. Trump’s campaign promises included building a wall — and making Mexico pay for it — as well as barring Muslims from entering the country.CreditDamon Winter/The New York Times

A Pledge With Appeal

Those who know Mr. Trump say that his attitude toward immigrants long predates his entry into politics.

“He’s always been fearful where other cultures are concerned and always had anxiety about food and safety when he travels,” said Michael D’Antonio, who interviewed him for the biography “The Truth About Trump.” “His objectification and demonization of people who are different has festered for decades.”

Friends say Mr. Trump, a developer turned reality TV star, grew to see immigration as a zero-sum issue: What is good for immigrants is bad for America. In 2014, well before becoming a candidate, he tweeted: “Our government now imports illegal immigrants and deadly diseases. Our leaders are inept.”

But he remained conflicted, viewing himself as benevolent and wanting to be liked by the many immigrants he employed.

Over time, the anti-immigrant tendencies hardened, and two of his early advisers, Roger J. Stone Jr. and Sam Nunberg, stoked that sentiment. But it was Mr. Trump who added an anti-immigrant screed to his Trump Tower campaign announcement in June 2015 in New York City without telling his aides.

“When do we beat Mexico at the border? They’re laughing at us, at our stupidity,” Mr. Trump ad-libbed. “They’re sending people that have lots of problems, and they’re bringing those problems,” he continued. “They’re bringing drugs; they’re bringing crime; they’re rapists.”

Democrats and some Republicans recoiled, calling Mr. Trump’s messaging damaging and divisive. But for the candidate, the idea of securing the country against outsiders with a wall had intoxicating appeal, though privately, he acknowledged that it was a rhetorical device to whip up crowds when they became listless.

Senator Tom Cotton, Republican of Arkansas, whom Mr. Trump consults regularly on the matter, said it was not a stretch to attribute Mr. Trump’s victory to issues where Mr. Trump broke with a Republican establishment orthodoxy that had disappointed anti-immigrant conservatives for decades.

“There’s no issue on which he was more unorthodox than on immigration,” Mr. Cotton said.

Image

“We have taken a giant steamliner barreling full speed,” the adviser Stephen Miller said of Mr. Trump’s immigration efforts. “Slowed it, stopped it, begun to turn it around and started sailing in the other direction.”CreditStephen Crowley/The New York Times

Mr. Miller and other aides had the task of turning those promises into a policy agenda that would also include an assault against a pro-immigration bureaucracy they viewed with suspicion and disdain. Working in secret, they drafted a half-dozen executive orders. One would crack down on so-called sanctuary cities. Another proposed changing the definition of a criminal alien so that it included people arrested — not just those convicted.

But mindful of his campaign promise to quickly impose “extreme vetting,” Mr. Trump decided his first symbolic action would be an executive order to place a worldwide ban on travel from nations the White House considered compromised by terrorism.

With no policy experts in place, and deeply suspicious of career civil servants they regarded as spies for President Barack Obama, Mr. Miller and a small group of aides started with an Obama-era law that identified seven terror-prone “countries of concern.” And then they skipped practically every step in the standard White House playbook for creating and introducing a major policy.

The National Security Council never convened to consider the travel ban proposal. Sean Spicer, the White House press secretary at the time, did not see it ahead of time. Lawyers and policy experts at the White House, the Justice Department and the Homeland Security Department were not asked to weigh in. There were no talking points for friendly surrogates, no detailed briefings for reporters or lawmakers, no answers to frequently asked questions, such as whether green card holders would be affected.

The announcement of the travel ban on a Friday night, seven days after Mr. Trump’s inauguration, created chaotic scenes at the nation’s largest airports, as hundreds of people were stopped, and set off widespread confusion and loud protests. Lawyers for the government raced to defend the president’s actions against court challenges, while aides struggled to explain the policy to perplexed lawmakers the next night at a black-tie dinner.

White House aides resorted to Google searches and frenzied scans of the United States Code to figure out which countries were affected.

But for the president, the chaos was the first, sharp evidence that he could exert power over the bureaucracy he criticized on the campaign trail.

“It’s working out very nicely,” Mr. Trump told reporters in the Oval Office the next day.

At a hastily called Saturday night meeting in the Situation Room, Mr. Miller told senior government officials that they should tune out the whining.

Sitting at the head of the table, across from Mr. Kelly, Mr. Miller repeated what he told the president: This is what we wanted — to turn immigration enforcement back on.

Mr. Kelly, who shared Mr. Trump’s views about threats from abroad, was nonetheless livid that his employees at homeland security had been called into action with no guidance or preparation. He told angry lawmakers that responsibility for the rollout was “all on me.” Privately, he told the White House, “That’s not going to happen again.”

Image

Demonstrating in January against the detention of travelers and refugees by border officials at Kennedy International Airport. The announcement of a travel ban set off widespread confusion and loud protests.CreditChristopher Lee for The New York Times

Forced to Back Down

Amid the turbulent first weeks, Mr. Trump’s attempt to bend the government’s immigration apparatus to his will began to take shape.

The ban’s message of “keep out” helped drive down illegal border crossings as much as 70 percent, even without being formally put into effect.

Immigration officers rounded up 41,318 undocumented immigrants during the president’s first 100 days, nearly a 40 percent increase. The Justice Department began hiring more immigration judges to speed up deportations. Officials threatened to hold back funds for sanctuary cities. The flow of refugees into the United States slowed.

Mr. Trump “has taken the handcuffs off,” said Steven A. Camarota of the Center for Immigration Studies, an advocacy group that favors more limits on immigration.

Mr. Obama had been criticized by immigrant rights groups for excessive deportations, especially in his first term. But Mr. Camarota said that Mr. Trump’s approach was “a distinct change, to look at what is immigration doing to us, rather than what is the benefit for the immigrant.”

The president, however, remained frustrated that the shift was not yielding results.

By early March, judges across the country had blocked his travel ban. Immigrant rights activists were crowing that they had thwarted the new president. Even Mr. Trump’s own lawyers told him he had to give up on defending the ban.

Attorney General Jeff Sessions and lawyers at the White House and Justice Department had decided that waging an uphill legal battle to defend the directive in the Supreme Court would fail. Instead, they wanted to devise a narrower one that could pass legal muster.

The president, though, was furious about what he saw as backing down to politically correct adversaries. He did not want a watered-down version of the travel ban, he yelled at Donald F. McGahn II, the White House counsel, as the issue came to a head on Friday, March 3, in the Oval Office.

It was a familiar moment for Mr. Trump’s advisers. The president did not mind being told “no” in private, and would sometimes relent. But he could not abide a public turnabout, a retreat. At those moments, he often exploded at whoever was nearby.

As Marine One waited on the South Lawn for Mr. Trump to begin his weekend trip to Palm Beach, Fla., Mr. McGahn insisted that administration lawyers had already promised the court that Mr. Trump would issue a new order. There was no alternative, he said.

“This is bullshit,” the president responded.

With nothing resolved, Mr. Trump, furious, left the White House. A senior aide emailed a blunt warning to a colleague waiting aboard Air Force One at Joint Base Andrews in Maryland: “He’s coming in hot.”

Already mad at Mr. Sessions, who the day before had recused himself in the Russia investigation, Mr. Trump refused to take his calls. Aides told Mr. Sessions he would have to fly down to Mar-a-Lago to plead with the president in person to sign the new order.

Over dinner that night with Mr. Sessions and Mr. McGahn, Mr. Trump relented. When he was back in Washington, he signed the new order. It was an indication that he had begun to understand — or at least, begrudgingly accept — the need to follow a process.

Still, one senior adviser later recalled never having seen a president so angry signing anything.

Video

As ICE arrests have gone up, deportations have gone down. Why? It’s partly because of the complex realities of a tough policy put in practice.Published OnDec. 23, 2017CreditImage by Melissa Lyttle for The New York Times

Soft Spot for ‘Dreamers’

As a candidate, Mr. Trump had repeatedly contradicted himself about the deportations he would pursue, and whether he was opposed to any kind of path to citizenship for undocumented immigrants. But he also courted conservative voters by describing an Obama-era policy as an illegal amnesty for the immigrants who had been brought to the United States as children.

During the transition, his aides drafted an executive order to end the program, known as Deferred Action for Childhood Arrivals. But the executive order was held back as the new president struggled with conflicted feelings about the young immigrants, known as Dreamers.

“We’re going to take care of those kids,” Mr. Trump had pledged to Senator Richard J. Durbin during a private exchange at his Inauguration Day luncheon.

The comment was a fleeting glimpse of the president’s tendency to seek approval from whoever might be sitting across from him, and the power that personal interactions have in shaping his views.

In 2013, Mr. Trump met with a small group of Dreamers at Trump Tower, hoping to improve his standing with the Hispanic community. José Machado told Mr. Trump about waking up at the age of 15 to find his mother had vanished — deported, he later learned, back to Nicaragua.

“Honestly,” Mr. Machado said of Mr. Trump, “he had no idea.”

Mr. Trump appeared to be touched by the personal stories, and insisted that the Dreamers accompany him to his gift shop for watches, books and neckties to take home as souvenirs. In the elevator on the way down, he quietly nodded and said, “You convinced me.”

Aware that the president was torn about the Dreamers, Jared Kushner, his son-in-law, quietly reached out in March to Mr. Durbin, who had championed legislation called the Dream Act to legalize the immigrants, to test the waters for a possible deal.

After weeks of private meetings on Capitol Hill and telephone conversations with Mr. Durbin and Senator Lindsey Graham, a South Carolina Republican supportive of legalizing the Dreamers, Mr. Kushner invited them to dinner at the six-bedroom estate he shares with his wife, Ivanka Trump.

But Mr. Durbin’s hope of a deal faded when he arrived to the house and saw who one of the guests would be.

“Stephen Miller’s presence made it a much different experience than I expected,” Mr. Durbin said later.

Image

Jairo Reyes of Arkansas, center left, and Karen Cuadillo of Florida, young undocumented immigrants shielded from deportation under an Obama-era policy, on Capitol Hill in September.CreditTom Brenner/The New York Times

Confronting the ‘Deep State’

Even as the administration was engaged in a court battle over the travel ban, it began to turn its attention to another way of tightening the border — by limiting the number of refugees admitted each year to the United States. And if there was one “deep state” stronghold of Obama holdovers that Mr. Trump and his allies suspected of undermining them on immigration, it was the State Department, which administers the refugee program.

At the department’s Bureau of Population, Refugees and Migration, there was a sense of foreboding about a president who had once warned that any refugee might be a “Trojan horse” or part of a “terrorist army.”

Mr. Trump had already used the travel ban to cut the number of allowable refugees admitted to the United States in 2017 to 50,000, a fraction of the 110,000 set by Mr. Obama. Now, Mr. Trump would have to decide the level for 2018.

At an April meeting with top officials from the bureau in the West Wing’s Roosevelt Room, Mr. Miller cited statistics from the restrictionist Center for Immigration Studies that indicated that resettling refugees in the United States was far costlier than helping them in their own region.

Mr. Miller was visibly displeased, according to people present, when State Department officials pushed back, citing another study that found refugees to be a net benefit to the economy. He called the contention absurd and said it was exactly the wrong kind of thinking.

But the travel ban had been a lesson for Mr. Trump and his aides on the dangers of dictating a major policy change without involving the people who enforce it. This time, instead of shutting out those officials, they worked to tightly control the process.

In previous years, State Department officials had recommended a refugee level to the president. Now, Mr. Miller told officials the number would be determined by the Department of Homeland Security under a new policy that treated the issue as a security matter, not a diplomatic one.

When he got word that the Office of Refugee Resettlement had drafted a 55-page report showing that refugees were a net positive to the economy, Mr. Miller swiftly intervened, requesting a meeting to discuss it. The study never made it to the White House; it was shelved in favor of a three-page list of all the federal assistance programs that refugees used.

At the United Nations General Assembly in September, Mr. Trump cited the Center for Immigration Studies report, arguing that it was more cost-effective to keep refugees out than to bring them into the United States.

Border wall prototypes in San Diego. The disorganization that marked Mr. Trump’s earliest actions on immigration have given way to a more disciplined approach that has yielded concrete results.CreditJenna Schoenefeld for The New York Times

More Disciplined Approach

Cecilia Muñoz, who served as Mr. Obama’s chief domestic policy adviser, said she was alarmed by the speed with which Mr. Trump and his team have learned to put their immigration agenda into effect.

“The travel ban was a case of bureaucratic incompetence,” she said. “They made rookie mistakes. But they clearly learned from that experience. For the moment, all of the momentum is in the direction of very ugly, very extreme, very harmful policies.”

By year’s end, the chaos and disorganization that marked Mr. Trump’s earliest actions on immigration had given way to a more disciplined approach that yielded concrete results, steered in large part by Mr. Kelly, a retired four-star Marine general. As secretary of homeland security, he had helped unleash immigration officers who felt constrained under Mr. Obama. They arrested 143,000 people in 2017, a sharp uptick, and deported more than 225,000.

Later, as White House chief of staff, Mr. Kelly quietly persuaded the president to drop his talk of Mexico paying for the wall. But he has advocated on behalf of the president’s restrictionist vision, defying his reputation as a moderator of Mr. Trump’s hard-line instincts.

In September, a third version of the president’s travel ban was issued with little fanfare and new legal justifications. Then, Mr. Trump overruled objections from diplomats, capping refugee admissions at 45,000 for 2018, the lowest since 1986. In November, the president ended a humanitarian program that granted residency to 59,000 Haitians since a 2010 earthquake ravaged their country.

At times, though, Mr. Trump has shown an openness to a different approach. In private discussions, he returns periodically to the idea of a “comprehensive immigration” compromise, though aides have warned him against using the phrase because it is seen by his core supporters as code for amnesty. During a fall dinner with Democratic leaders, Mr. Trump explored the possibility of a bargain to legalize Dreamers in exchange for border security.

Mr. Trump even told Republicans recently that he wanted to think bigger, envisioning a deal early next year that would include a wall, protection for Dreamers, work permits for their parents, a shift to merit-based immigration with tougher work site enforcement, and ultimately, legal status for some undocumented immigrants.

The idea would prevent Dreamers from sponsoring the parents who brought them illegally for citizenship, limiting what Mr. Trump refers to as “chain migration.”

“He wants to make a deal,” said Mr. Graham, who spoke with Mr. Trump about the issue last week. “He wants to fix the entire system.”

Yet publicly, Mr. Trump has only employed the absolutist language that defined his campaign and has dominated his presidency.

After an Uzbek immigrant was arrested on suspicion of plowing a truck into a bicycle path in Lower Manhattan in October, killing eight people, the president seized on the episode.

Privately, in the Oval Office, the president expressed disbelief about the visa program that had admitted the suspect, confiding to a group of visiting senators that it was yet another piece of evidence that the United States’ immigration policies were “a joke.”

Even after a year of progress toward a country sealed off from foreign threats, the president still viewed the immigration system as plagued by complacency.

“We’re so politically correct,” he complained to reporters in the cabinet room, “that we’re afraid to do anything.”