Senate Majority Leader Mitch McConnell, center, R-Ky., walks to his office early Saturday, Jan. 20, 2018, at the Capitol in Washington. The federal government shut down at the stroke of midnight Friday, halting all but the most essential operations. (AP Photo/Jose Luis Magana)

Sen. Kamala Harris D-Calif., speaks during a rally in support of the Deferred Action for Childhood Arrivals (DACA), and to avoid the government shut down on Capitol Hill, Friday, Jan. 19, 2018, in Washington. ( AP Photo/Jose Luis Magana)

WASHINGTON — The president was angry.

He'd been fuming since the previous night, mad at his chief of staff John Kelly for saying on television Wednesday that Trump's views on a border wall had "evolved." To his base, that's a worse offense than shutting down the government, Trump told a confidant. He picked up his phone and began tweeting.

In a single, baffling message, he suggested he wasn't on board with his party's plan to avert a government shutdown Friday night. His allies in Congress were confused, frustrated and unnerved by the tweet. Republicans picked up the phones to the White House. This needed fixing.

The episode was one of several that eroded trust and derailed negotiations between the White House and lawmakers from both parties in the final run-up to the government shutdown. Lawmakers who wanted to negotiate over a "big deal" on immigration and spending ultimately wound up haggling over how many more days they needed to talk. Cheeseburgers and chats at the White House could not yield lasting progress.

The president who promised to be master dealmaker at times looked more like a saboteur.

__

The week did not start well for Republicans.

Trump officials and a few GOP senators were still struggling to explain whether the president had disparaged African nations as "shithole countries" in a White House meeting last week. The comments fired up liberal activists, who pushed Democrats to dig in on their instance that any budget measure come with protections for the young immigrants known as "dreamers" who are facing deportation.

There would be consequences — even primary challenges — for Senate Democrats who balked.

By Wednesday, when Senate Democrats huddled behind closed doors in the Capitol to discuss their options, the impact of those efforts was becoming clear. Up to that point, only those Democrats with 2020 ambitions and the more liberal members had supported the bare-knuckles strategy. But faced with a GOP proposal of a four-week funding bill that would keep the talks going, the tide began to turn.

Inside the caucus room that day, an almost-organic shift spread across the senators. It felt like Groundhog Day, and few members believed things would be any different four weeks later.

They decided to take a stand. When they left the meeting, Schumer announced the party was united in opposition against the GOP's 30-day spending plan.

__

Republicans had other problems to tackle first. House conservatives weren't yet backing that temporary deal.

Trump worked the phones from Air Force One Thursday afternoon as he traveled to western Pennsylvania to promote the recently-passed tax overhaul.

He called Rep. Mark Meadows, R-N.C., the leader of the House Freedom Caucus, who was huddling in the office of Rep. Jim Jordan, R-Ohio, and a few other like-minded congressmen.

The conversation with the president included a pledge to lift the cap on military spending in subsequent legislation, according to a source familiar with the discussion, one of several people who requested anonymity to discuss the budget negotiations because they were not authorized to disclose private deliberations.

The White House was clearly proud of Trump's work.

After the conversation, Meadows left Jordan's office to share his thoughts with the House Speaker Paul Ryan, stopping to do a CNN interview along the way. By the time he reached the speaker's office, the White House had already notified Ryan that the Freedom Caucus was on board.

__

It was shortly after 7:30 p.m. Thursday when the Republican-led House passed the 30-day spending plan, overcoming solid Democratic opposition to approve legislation that included funding for the children's health insurance program, but did nothing to protect the young immigrants. Just six Democrats voted yes.

With less than 29 hours until the shutdown deadline, attention quickly shifted to the Senate. Republicans control the chamber, but they would need at least nine Democrats to support the legislation to reach the key 60-vote threshold.

In a sign of the trouble to come, the Senate couldn't even agree on when to adjourn for the night.

When lawmakers did return Friday morning, a shutdown suddenly seemed more likely than ever. The White House announced that Trump would not travel to his lavish Florida resort, where he was slated to attend a glitzy weekend gala to mark the anniversary of his inauguration.

The president had voiced frustration about the cancellation, but signed off on the change, according to a person who spoke with the president. If a deal was struck Friday night to keep the government running, he would depart for Mar-a-Lago on Saturday instead.

The White House and Republican lawmakers spent the morning blaming Democrats for putting the country on the brink of a shutdown. Meanwhile, Trump privately reached out to Schumer to discuss the contours of "a big deal," according to a source familiar with the conversation. The two New Yorkers agreed that short-term spending plans were largely a waste of time and agreed to meet in person to discuss a way forward.

__

Trump and Schumer each brought just one aide to Friday's Oval Office lunch. The president was flanked by chief of staff John Kelly, while Schumer brought his own chief of staff.

Over cheeseburgers, they discussed a broad deal that would include a large increase in defense and border spending in exchange for protections for the young immigrants. Schumer suggested a two- or three-day resolution would give congressional negotiators time to nail down the details. He left the White House without a deal, but believed he had an understanding they were close.

As news of the Schumer meeting spread, the White House sought to reassure Republican leaders that Trump wasn't making any major policy concessions. Sen. John Cornyn of Texas told reporters Trump had simply told Schumer to work things out with Ryan and Senate Majority Leader Mitch McConnell.

A few hours later, Trump called Schumer — but the conversation had changed. He wanted to talk about an apparent deal for a three-week spending bill he believed had been struck by leaders by both parties. Schumer was confused and said it was the first he had heard of it, according to a person familiar with the conversation.

The president encouraged Schumer to work it out with McConnell. McConnell, unsure what Trump might support, encouraged Schumer to work it out with the White House.

The White House did not immediately comment on the conversations.

Trump called Schumer one more time as the evening turned to night, this time with chief of staff Kelly on the phone. He raised new concerns about the deal they had discussed during lunch. In a subsequent phone call with Schumer, Kelly said the deal was too liberal.

__

Trump spent much of the rest of the evening watching cable television coverage of the impending shutdown and talking on the phone with his network of outside advisers. He told one person he was convinced Democrats would take the blame for the shutdown. He also expressed annoyance he was not at Mar-a-Lago.

Speaking on the Senate floor after midnight, when the shutdown had formally begun, Schumer expressed disappointment for the deal that almost was.

"The same chaos, the same disarray, the same division and discord on the Republican side that's been in the background of these negotiations for months, unfortunately appears endemic," Schumer said. He added, "This is no way to conduct the nation's business."