WASHINGTON — Mitch McConnell, the Senate majority leader, went to bed Wednesday night cautiously optimistic that a shutdown crisis that had stretched back to December had finally ended.
Then President Trump awoke in a rage Thursday, feeling cornered into accepting a bipartisan funding deal struck earlier in the week that would deprive him once again of money for his long-promised wall along the southwestern border. Conservative commentators who had been cajoled into accepting the deal Wednesday were breaking their silence on Thursday.
By midmorning, after a particularly unpleasant meeting with the secretary of homeland security, Kirstjen Nielsen, the president was threatening to torpedo the deal, according to two people briefed on the exchange. Several hours and several phone calls later, Mr. McConnell had persuaded Mr. Trump to once again agree to sign the bill to avert another government shutdown looming at midnight Friday.
But persuasion came at a price: The president would declare a national emergency to try to secure wall funding without congressional approval, he told the majority leader — and Mr. McConnell would have to back him.
“I indicated I’m going to support the national emergency declaration.” Mr. McConnell said Thursday afternoon from the Senate floor, mumbling and visibly weary after his conversation with the president.
“You are rude!” barked Senator Charles E. Grassley, Republican of Iowa, who had not finished a floor speech when his leader interrupted him.
It was a fitting moment for a surreal, discordant day.
Mr. McConnell’s concession, on the heels of the president’s bigger capitulation over wall funding, capped a wrenching month of political realignment, as Mr. Trump’s power has waned in the face of a divided Congress and his understanding of the Constitution’s separation of powers has been challenged. A 35-day government shutdown, the largest in the nation’s history, had depleted his party’s political reserves and made another impasse unthinkable.
“Shutdowns are a total misery march,” said Senator Shelley Moore Capito, Republican of West Virginia. “Time makes it worse. And that’s what happened here.”
And by maneuvering negotiations to avert another shutdown to the leaders of the House and Senate Appropriations Committees, congressional leaders put Democrats at a distinct advantage. Appropriators knew how to reach a deal — and were willing to do it without the White House in the room.
“I think the president has finally learned that shutdowns don’t work — at least I hope he has learned that — because you never know,” said Senator Patrick J. Leahy of Vermont, the ranking Democrat on the Senate Appropriations Committee.
After the last shutdown, the majority leader appeared ready for some normalcy on Capitol Hill. The decision by Mr. McConnell and Speaker Nancy Pelosi to appoint a 17-member conference committee to produce a bill that would fund the government through the end of the current fiscal year effectively sidelined the White House from the talks, according to congressional aides from both parties.
Largely absent was Jared Kushner, the president’s son-in-law, who bragged that he was instrumental in securing a bipartisan criminal justice bill last year but who aggravated Republicans and Democrats alike in December by advising the president to embrace the shutdown.
Mr. Kushner was present in the Oval Office for a few meetings between Mr. Trump and Senator Richard C. Shelby, Republican of Alabama and the chairman of the Appropriations Committee, according to a congressional aide. But Mr. Kushner, who has fashioned himself as the Trump White House’s master deal maker, said he was stepping back to focus on a far more ambitious project, Middle East peace, according to two senior administration officials.
Absent, too, was Vice President Mike Pence, whom the president consistently undercut in December during the first round of shutdown talks when he offered compromise solutions. Republican senators repeatedly questioned the vice president on whether he was speaking for himself or the president when he weighed in on topics related to the negotiations.
Then, as negotiators closed in on a deal, Mr. Pence flew away — for a trip to Europe.
Left to their own devices, congressional negotiators began their work in earnest on Jan. 29, when Representative Nita M. Lowey, Democrat of New York and the chairwoman of the House Appropriations Committee, convened a meeting of party lawmakers in the ornate office of Senator Chuck Schumer of New York, the minority leader, to settle on a unified strategy.
They agreed to table some of the most complex immigration issues, including the fate of young immigrants brought to the country illegally as children, to focus on keeping the mileage and funding for any border barrier as stingy as possible, according to Democratic aides.
Ms. Lowey and Mr. Shelby had little difficulty arriving at a general range for barrier funding. Both sides agreed to authorize $ 1.3 billion to $ 1.6 billion for fencing, not a hard call considering both chambers of Congress had already passed legislation last year authorizing similar expenditures — only to be rejected by Mr. Trump. They ended up approving $ 1.375 billion for 55 miles of steel-post fencing, 10 miles less than the deal that they had reached over the summer — and that the president had rejected.
The biggest snag came as negotiators neared a deal on Sunday: Liberals led by Representative Lucille Roybal-Allard, Democrat of California, pushed a plan to cap the number of detention beds used for migrants. Mr. Shelby presented the proposal to Mr. Trump, who immediately rejected it, and Ms. Pelosi immediately withdrew her committee members from the talks.
But the move, which Ms. Pelosi’s office portrayed as a “breakdown” in negotiations, was really intended to assuage critics on the left who said House Democrats were not doing enough to counter aggressive immigrant roundups in areas far from the border.
On Monday morning, as Ms. Pelosi drove to the airport in San Francisco for a flight back to Washington, she informed Ms. Lowey and Ms. Roybal-Allard that the proposal was “too hard to explain publicly” and ordered them to restart the talks.
By Monday night, the negotiators had reached an agreement.
That is when Mr. McConnell’s troubles really began.
Mr. McConnell, burned by the last round of negotiations that led to the shutdown in December, concluded that none of Mr. Trump’s previous emissaries to Capitol Hill could be trusted to speak for a president prone to changing his position on a whim.
With Mr. Kushner and the vice president absent, Mick Mulvaney, the interim White House chief of staff, was left to monitor the discussions. An avid supporter of government shutdowns when he was a Republican congressman from South Carolina, Mr. Mulvaney caused considerable tension.
Mr. McConnell and his staff were especially annoyed by Mr. Mulvaney’s performance on Sunday on the political talk shows, saying he seemed giddy and enthusiastic about the possibility of another shutdown, according to three people familiar with the situation.
After Mr. Mulvaney on Sunday refused to rule out a shutdown, an incensed Mr. Shelby referred to Mr. Mulvaney as “dangerous” in the negotiations during a check-in session with lawmakers, according to a member of the conference committee. He was infuriated all over again on Thursday, believing Mr. Mulvaney was behind Mr. Trump’s change of heart.
Mr. Shelby, asked about his views on Mr. Mulvaney, declined to comment.
The majority leader, sentimental as a scythe and not one for small talk, decided it was up to him. He began speaking with Mr. Trump three or four times a day, and urged others to do the same, according to several people close to the negotiations.
“I want you all to start calling the president directly,” Mr. McConnell told a group of senior Republicans last week after a conference lunch, according to two people in attendance. “He’s easy to get on the phone.”
Mr. McConnell viewed his role as equal parts cajoler and instructor. He patiently (and fruitlessly) argued against the emergency declaration, which he sees as usurping congressional authority to splinter Senate Republicans. He also used the check-ins to collect intelligence about Mr. Trump’s mind-set.
To sell the president on the deal, he argued that it was a “big down payment” on the wall and offered to support moves by the president to transfer some funding from other agencies to border barrier projects if he ditched the emergency declaration. But the core of his case, people close to Mr. McConnell said, was the argument that the deal reached by negotiators was actually a “victory” over Ms. Pelosi, thanks to his success in fighting attempts to reduce the number of detention beds.
Mr. Trump never really bought it.
But Mr. McConnell is nothing if not adaptable. During his final call with Mr. Trump, he looped in the White House counsel, Pat Cipollone, who expressed misgivings about the emergency declaration, telling an annoyed Mr. Trump that it would prompt several serious lawsuits.
Mr. McConnell, quickly shifting from opposing the declaration to managing its rollout, snapped back, “Who cares? This is America — everybody sues everybody else,” according to a person the leader spoke to late Thursday.