When President Trump made a rare journey to the Capitol last week, he was expected to strategize about how to end the government shutdown he instigated. Instead, he spent the first 20-odd minutes delivering a monologue about “winning.”

“We’re winning” on North Korea, the president told Republican senators Wednesday at a closed-door luncheon. “We’re winning” on Syria and “we’re winning” on the trade war with China, too. And, Trump concluded, they could win on immigration if Republicans stuck together through what is now the longest federal government shutdown in U.S. history, according to officials who attended the presidential pep talk.

The problem was that Trump offered no path to victory — other than brinkmanship.

Talks between the two parties remained stalled this weekend after the president torpedoed his last negotiating session with House Speaker Nancy Pelosi (D-Calif.) and Senate Minority Leader Charles E. Schumer (D-N.Y.) by walking out of the room.

With Trump determined to deliver on his signature campaign promise of building a border wall and Democrats standing firm against what they view as an immoral and ineffective solution to illegal immigration, there is no end in sight to the dysfunction.

Trump was nevertheless confident on Saturday about his handling of the standoff. “I do have a plan on the Shutdown,” he tweeted. “But to understand that plan you would have to understand the fact that I won the election, and I promised safety and security for the American people.”

The president who pitched himself to voters as a world-class dealmaker has proven to be an unreliable negotiator. Grappling for the first time with a divided government, Trump has contradicted himself, sent miscues and spread falsehoods. He has zigzagged between proudly claiming ownership of the shutdown and blaming it on Democrats, and between nearly declaring a national emergency to construct the wall without congressional approval and backing off such a legally and politically perilous action.

As Washington braced for a snowstorm on Saturday morning, Trump was hunkered down in his private quarters at the White House and tweeting taunts to Democrats. “I am in the White House waiting for you!” he wrote in one message. The president claimed in another that there was no chaos in his administration — “In fact, there’s almost nobody in the W.H. but me,” he wrote — and argued that the onus was on Democrats to buckle and agree to fulfill his demand for $5.7 billion in wall funding.

The government could reopen if Trump agreed to sign legislation funding the government, versions of which already have passed both chambers of Congress, and table the polarizing debate over border security.

In the weeks leading up to December’s deadline to fund the government, Trump was warned repeatedly about the dangers of a shutdown but still opted to proceed, according to officials with knowledge of the conversations.

Senate Majority Leader Mitch McConnell (R-Ky.) told the president that he had no leverage and that, without a clear strategy, he would be “boxed in a canyon.” He tried to make the case to Trump that even if Pelosi and Schumer were interested in cutting a deal with him, they would be constrained from compromising because of internal Democratic Party pressures to oppose Trump’s wall, these officials said.

Then-House Speaker Paul D. Ryan (R-Wis.) talked with Trump by phone for 45 minutes the day before the shutdown, warning that he saw no way to win as he paced in a Capitol hallway just outside a conference room where House Republicans were meeting. Then-House Majority Leader Kevin McCarthy (R-Calif.) warned about the perils of a shutdown during the Christmas season.

Inside, some of the more hard-line members urged a showdown over border wall funding, arguing that Trump’s core supporters would revolt otherwise. But McCarthy asked, “Tell me what happens when we get into a shutdown? I want to know what our next move is.”

A senior White House official characterized Republican leaders as “supportive” throughout the shutdown.

President Trump salutes as a U.S. Customs and Border Protection helicopter passes over the Rio Grande on the southern border in McAllen, Tex., on Jan. 10. (Evan Vucci/AP)

Trump’s advisers are scrambling to build an exit ramp while also bracing for the shutdown to last weeks longer. Current and former aides said there is little strategy in the White House; people are frustrated and, in the words of one, “freaking out.”

The shutdown was born out of frustration. Angry that he was stymied by party leaders and his own aides from getting more money for the wall in 2018, rattled by conservative criticism and stung by his party’s midterm defeats, Trump decided in late December to plunge into a border fight after being encouraged by Reps. Mark Meadows (R-N.C.) and Jim Jordan (R-Ohio), both hard-line conservatives. It was a startling decision to McConnell and others, who thought they had White House assurances that a shutdown would be avoided.

“He has no choice here,” said Newt Gingrich, a Trump supporter who was House speaker in the Clinton administration and during the second-longest shutdown, an episode widely viewed as a disaster for Republicans. “He has to win. His entire reputation, his entire relationship with the base, it’s all a function of being committed on big things and not backing down. If he backs down on this, Pelosi will be so emboldened that the next two years will be a nightmare.”

As the shutdown dragged on, aides said, Trump has bragged that he looked “tough” and that his supporters had his back. He has viewed the past three weeks more as an hour-to-hour public relations fight than as a painstaking legislative negotiation, trying to sway opinion with a prime time Oval Office address and a high-profile trip to Texas to survey the U.S.-Mexico border.

“He is determined, as he has been from day one, not to break faith with the people who brought him to the presidency,” said William A. Galston, a senior fellow in governance at the Brookings Institution. “I’ve never seen a president who is more indifferent to expanding his appeal.”

Trump has exhibited more determination than calculation. Over the holidays, he inhabited the White House largely alone, tweeting out his demands and grievances. Several senior West Wing officials described the building as a “ghost town” or a “no man’s land.”

Only after Christmas did administration officials begin realizing the full scale of the logistical problems a prolonged shutdown would cause. Aides said Trump has been largely uninterested in the minutiae of managing government agencies and services.

During negotiation sessions, Trump’s attention has veered wildly. At one such meeting with Pelosi and Schumer in the White House Situation Room earlier this month, the president went on a long diatribe about unrelated topics. He trashed the Iran nuclear deal, telling Democrats they should give him money for the wall because, in his view, they gave President Barack Obama money for the agreement with Tehran. He boasted about his wisdom in ordering the withdrawal of U.S. troops from Syria. And he raised the specter of impeachment, accusing Pelosi of wanting to try to force him from office — which she denied.

Eventually, he was moved back to the budget talks.

During last week’s Senate lunch, Trump praised his relationship with Chinese President Xi Jinping and North Korean leader Kim Jong Un while delineating his foreign policy accomplishments. “I don’t know why I get along with all the tough ones and not the soft ones,” he quipped, referring to dictators and allies, according to attendees.

Also at the lunch, Trump asked Republican National Committee Chairwoman Ronna McDaniel to stand up for applause and thanked Sen. Rand Paul (R-Ky.) for supporting him on TV. He obliquely knocked the late senator John McCain (R-Ariz.) for not voting to repeal the Affordable Care Act, attendees said.

Sen. Roger Wicker (R-Miss.) warned Trump that declaring a national emergency could set a precedent for Democrats to follow on other issues, should they win the White House. But Trump assured them he would win reelection in 2020.

Vice President Pence speaks to reporters on Jan. 9 after a meeting with congressional leadership at the White House. (Jabin Botsford/The Washington Post)

Vice President Pence, after being roasted by critics last month for sitting idly during Trump’s contentious televised meeting with Pelosi and Schumer, jumped into the negotiations in recent weeks, doing what one of his longtime allies described as a “reimagining” of his dutiful and low-key approach.

But Pence’s efforts were challenged from the start as his initial pitch to Senate Democrats — in which he floated lowering the demand from $5.7 billion for wall funds — was dismissed by Trump days later, even though Pence delivered the offer at the president’s behest.

Still, Pence, whose aides say he has a preternatural calm, shifted and became a salesman for the president’s position and worked to lay the groundwork for possible executive action.

Democratic aides, however, were irritated by Pence’s dogged emphasis on a crisis during last weekend’s talks and the administration’s lack of preparation on the exact numbers of its requests.

“They’re sitting there going, ‘Where are the numbers? What is going on here?’ ” said a senior House Democratic aide briefed on the discussions.

Some White House officials privately groused that meetings were pointless and believed it was beneath the office of the vice president to negotiate with congressional staffers.

President Trump holds up a photo of a “typical standard wall design” as he speaks on Jan. 11 during a roundtable discussion on border security in the Cabinet Room of the White House. (Jabin Botsford/The Washington Post)

Exasperated, a small group of Republican lawmakers tried to determine a way out last week. Led by Sen. Lindsey O. Graham (S.C.), they met Wednesday in Graham’s office with White House legislative affairs director Shahira Knight and senior adviser and Trump son-in-law Jared Kushner to discuss a broader immigration deal that could include protections for undocumented children in exchange for $5.7 billion in wall funding.

Graham saw an opening to broker an accord between Trump, whom he had come to call a friend, and Senate GOP moderates who were urging aggressive steps to reopen the government.

Following the passage of criminal-justice reform legislation that he championed, Kushner carried himself with the confidence of a White House chief of staff, according to congressional aides.

One GOP senator, who like other officials spoke on the condition of anonymity to speak candidly, said he appreciated Kushner’s “good attitude” but said that senators “really doubt whether he can do anything” to convince Trump to soften his hard-line tactics and back a bipartisan immigration deal.

After meeting with McConnell last Thursday, Graham and three colleagues — Sens. Lamar Alexander (R-Tenn.), Susan Collins (R-Maine) and Lisa Murkowski (R-Alaska) — presented their plan to Pence. He then relayed the idea to Trump, who was flying to Texas for his border tour.

But the president said no. Pence then told Graham and Alexander that Trump appreciated their proposal but was not interested in re-opening the government until the Democrats were willing to negotiate on the wall.

“I have never been more depressed about moving forward than I am right now,” Graham told reporters that afternoon. He then walked off, muttering: “I’m going to the gym.”

The next day, Graham called for drastic measures: “It is time for President Trump to use emergency powers.”