President Donald Trump and First Lady Melania Trump return to the White House following a weekend trip to Mar-a-Lago. Trump’s ping-ponging from deal making to feuding, from elation to fury, has come to define the contentious immigration talks between the White House and Congress, perplexing members of both parties as they navigate the president’s vulgarities, his combativeness and his willingness to suddenly change his position.

WASHINGTON – When President Donald Trump spoke by phone with Sen. Richard Durbin around 10:15 a.m. last Thursday, he expressed pleasure with Durbin’s outline of a bipartisan immigration pact and praised the high-ranking Illinois Democrat’s efforts, according to White House officials and congressional aides.

The president then asked if Sen. Lindsey Graham, R-S.C., his onetime foe turned ally, was on board, which Durbin affirmed. Trump invited the lawmakers to visit with him at noon, the people familiar with the call said.

But when they arrived at the Oval Office, the two senators were surprised to find that Trump was far from ready to finalize the agreement. He was “fired up” and surrounded by hard-line conservatives such as Sen. Tom Cotton, R-Ark., who seemed confident that the president was now aligned with them, according to one person with knowledge of the meeting.

Trump told the group he wasn’t interested in the terms of the bipartisan deal that Durbin and Graham had been putting together. And as he shrugged off suggestions from Durbin and others, the president called nations from Africa “shithole countries,” denigrated Haiti and grew angry. The meeting was short, tense and often dominated by loud cross-talk and swearing, according to Republicans and Democrats familiar with the meeting.

Trump’s ping-ponging from deal making to feuding, from elation to fury, has come to define the contentious immigration talks between the White House and Congress, perplexing members of both parties as they navigate the president’s vulgarities, his combativeness and his willingness to suddenly change his position. The blowup has derailed those negotiations yet again and increased the possibility of a government shutdown over the fate of hundreds of thousands of young undocumented immigrants known as “dreamers.”

This account of the events surrounding Thursday’s explosive meeting is based on interviews with more than a dozen White House officials, Capitol Hill aides and lawmakers.

The fight has left congressional leaders unsure of whether they will eventually come to an agreement. Some remain optimistic that Trump can be walked back to the political center and will cut a deal that expands border security while protecting those under the Deferred Action for Childhood Arrivals (DACA) program, which Trump has ordered ended.

“The president is indispensable to getting a deal,” Graham said in an interview. “Time will tell.”

Last Thursday was a critical moment in the stalled negotiations, revealing the president’s priorities even as the discussion fell apart.

Trump complained that there wasn’t enough money included in the deal for his promised wall along the U.S.-Mexico border. He also objected that Democratic proposals to adjust the visa lottery and federal policy for immigrants with temporary protected status were going to drive more people from countries he deemed undesirable into the United States instead of attracting immigrants from places like Norway and Asia, people familiar with the meeting said.

Attendees who were alarmed by the racial undertones of Trump’s remarks were further disturbed when the topic of the Congressional Black Caucus (CBC) came up, these people said.

At one point, Durbin told the president that members of that caucus – an influential House group – would be more likely to agree to a deal if certain countries were included in the proposed protections, according to people familiar with the meeting.

Trump was curt and dismissive, saying he was not making immigration policy to cater to the CBC and did not particularly care about that bloc’s demands, according to people briefed on the meeting. “You’ve got to be joking,” one adviser said, describing Trump’s reaction.

White House Chief of Staff John Kelly was in the room and was largely stone-faced, not giving any visible reaction when Trump said “shithole countries” or when he said Haitians should not be part of any deal, White House advisers said.

At one point, Graham told Trump he should use different language to discuss immigration, people briefed on the meeting said.

As Trump batted back the Democrats, he was urged on by Republican lawmakers. Rep. Bob Goodlatte, R-Va., told Graham and Durbin their proposal would not fly, and he told the group they should instead embrace his more conservative bill. Durbin was not interested, White House officials said.

After Graham left, he told associates that he was disturbed by what he heard in the Oval Office, according to people who spoke with him, and that it was evident the deal’s antagonists had gotten to Trump. Graham and Durbin also told allies that they were stunned that the other lawmakers were present – and that Trump’s tone seemed so different than it had been days or even hours before, according to people close to them.

Graham declined to comment on the president’s reported obscenity. He has told others in his circle that commenting would only hurt the chance of a deal and that he wants to keep a relationship with the president.

There had initially been hope for the Thursday meeting. Trump had told lawmakers during a partially televised session two days earlier that he was flexible. “I’ll sign it,” he said Tuesday of whatever bill was brought to him. He even said he would be willing to lock the door of the Cabinet room if they wanted to negotiate at the White House, according to people who heard his comments.

Trump went on to say at the earlier meeting that he wanted a deal and that even those in the conservative House Freedom Caucus should work with Durbin. In the hours and days afterward, a bipartisan group of senators – Graham, Durbin, Jeff Flake, R-Ariz., Robert Menendez, D-N.J., and Sens. Michael Bennet, D, and Cory Gardner, R, of Colorado – began meeting and broadly agreed to a proposal.

But some White House officials, including conservative adviser Stephen Miller, feared that Graham and Durbin would try to trick Trump into signing a bill that was damaging to him and would hurt him with his political base. As word trickled out Thursday morning on Capitol Hill that Durbin and Graham were heading over to the White House, legislative affairs director Marc Short began to make calls to lawmakers and shared many of Miller’s concerns.

Soon, Goodlatte, one of the more conservative House members on immigration, was headed to the White House. Trump also called House Majority Leader Kevin McCarthy, R-Calif., and asked him to come, McCarthy said. Sens. David Perdue, R-Ga., and Cotton were also invited to rush over.

In the late morning, before Durbin and Graham arrived, Kelly – who had already been briefed on the deal – talked to Trump to tell him that the proposal would probably not be good for his agenda, White House officials said. Kelly, a former secretary of homeland security, has taken an increasingly aggressive and influential role in the immigration negotiations, calling lawmakers and meeting with White House aides daily – more than he has on other topics. He has “very strong feelings,” in the words of one official. But he’s not a lone voice. Trump in recent weeks has also been talking more to conservatives such as Rep. Mark Meadows, R-N.C., on immigration, these people said.

White House officials say Kelly is determined to secure a deal on dreamers and border security and has told Trump that the southwestern border is worse than it was a few years ago – and that he can be the president to change the status quo.

“Once we saw what was going on in the meeting a few days earlier, we were freaked out,” said immigration hard-liner Mark Krikorian, who runs the Center for Immigration Studies. Trump, he said, “has hawkish instincts on immigration, but they aren’t well-developed, and he hasn’t ever been through these kind of legislative fights.”

After the Thursday meeting, Trump began telling allies that the proposal was a “terrible deal for me,” according to a friend he spoke with, and that Kelly and other aides and confidants were correct in advising him to back away.

“It wasn’t a serious proposal. It was not viewed as a serious proposal because it did so little to address the immigration issues that the president has been vocal about,” said Meadows, who leads the conservative House Freedom Caucus. “It was, if I had to put it in a 1-to-10 range, with 10 being the most conservative and 1 being the most liberal, I would give it a 2.5.”

Trump was not particularly upset by the coverage of the meeting and his vulgarity after it was first reported by The Washington Post, calling friends and asking how they expected it to play with his political supporters, aides said.

“Everyone was saying it would help with the base,” which would agree with his characterization, one person who spoke with the president said.

By Thursday evening, many White House aides were concerned that the story was exploding beyond the usual level for a Trump controversy, but they carried on with their plans for the night: a send-off for deputy national security adviser Dina Powell, a former Goldman Sachs executive and ally of Jared Kushner and Ivanka Trump. Nearly every top official ducked into the exclusive Italian restaurant Cafe Milano in Georgetown to toast Powell. There was little effort to significantly push back on the story that night because aides knew that Trump had said it and that the president wasn’t even too upset, according to people involved in the talks.

Then Friday morning, Trump appeared to suggest in a tweet that he had not used the objectionable word at all: “The language used by me at the DACA meeting was tough, but this was not the language used.”

Three White House officials said Perdue and Cotton told the White House that they heard “shithouse” rather than “shithole,” allowing them to deny the president’s comments on television over the weekend. The two men initially said publicly that they could not recall what the president said.

Representatives for both men declined to comment.

Going forward, a path to an immigration deal remains hazy.

“I expect that we’ll get more Republican support for the proposal because it’s really the only game in town. I expect there will be more negotiations – we didn’t write the Bible,” Graham said Monday. “We wrote a proposal that over time we can make it better.”

Meadows said he and Goodlatte were working to add a merit-based immigration policy to their conservative version. He said a majority of Republicans were not going to line up behind Graham and Durbin and should instead rally behind his proposal, which is unlikely to win support with Democrats.

“Based on what they proposed originally, Durbin and Graham are running a marathon, and they’re only in Mile 2,” Meadows said.