In the end, it was neither the self-proclaimed deal-making President Trump nor seasoned congressional leaders who found the path to end the three-day government shutdown.
Rather, the agreement emerged from a fledgling caucus of impassioned moderates from both political parties who — if they aren't sidelined in days ahead by a partisan resurgence — could grow into a new power center in the Senate.
The House and Senate both approved a compromise Monday — and Trump later signed the bill — to extend government spending until Feb. 8, clearing the way for government offices to reopen Tuesday.
The deal was worked out by a gang of 30 or so senators calling themselves the Common Sense Coalition, which grew in numbers over the weekend during frantic negotiations to end the standoff.
Now many lawmakers in both parties are hoping the moderate group will continue to exert its influence to break the logjam, even as a few ideological factions were plotting how to stamp it out.
Democrats, in particular, need to hold the center together to quickly craft an immigration deal to protect "Dreamers," as the party comes under criticism from its progressive wing. Liberals complained Monday that Senate Minority Leader Charles E. Schumer (D-N.Y.) and others folded by agreeing to reopen government without extracting a firm commitment that Republicans would keep their promise to consider a bipartisan bill to help the immigrants.
The Senate voted overwhelmingly, 81-18, to pass the three-week spending bill. In the House, Speaker Paul D. Ryan (R-Wis.) marshaled his majority for approval, 266-150, with six Republicans and 144 Democrats opposed.
In return for Democrats' support, Senate Majority Leader Mitch McConnell (R-Ky.) agreed to consider legislation to help Dreamers as part of an immigration compromise that is also likely to include border security and other measures. Protections against the deportation of Dreamers — young immigrants who were brought to the country illegally as children — are at risk because Trump is terminating the Obama-era Deferred Action for Childhood Arrivals program as of March 5. A federal court has ordered the protections continued, however, and they could remain in effect for many months.
"Now comes the test, the real test, of whether we can get this done," said Sen. Richard J. Durbin (D-Ill.), who called the Dreamers "the civil rights issue of our time." He promised Democrats would not relent. "To all the Dreamers who are watching today: Don't give up."
Those promises, though, were met with deep skepticism by immigrant advocates for the nearly 700,000 young people.
"It's official: Chuck Schumer is the worst negotiator in Washington," Murshed Zaheed, political director of Credo, an immigration advocacy group, said in a statement. He said any plan that relies on Republican leaders to keep their promises is "doomed to fail."
Trump capitalized on the divisions, declaring "Democrats caved," in a fundraising email to his supporters. After voting, he quickly welcomed some of the most restrictionist immigration senators to the White House, including several whose influence had quashed previous bipartisan deals.
Democrats were initially cool to McConnell's offer when it was presented Sunday, wanting more than a promise that GOP leaders, who control the Senate floor schedule, would seriously consider an immigration bill.
Fifteen Democrats, including California Sens. Kamala Harris and Dianne Feinstein and other leading liberals, voted to continue the filibuster, as did Sen. Bernie Sanders, the Vermont independent. Two Republicans, Sens. Rand Paul of Kentucky and Mike Lee of Utah, who oppose spending levels, voted with them.
Harris told reporters afterward it was "foolhardy" to believe McConnell. "I refuse to put the lives of nearly 700,000 young people in the hands of someone who has repeatedly gone back on his word," Harris said on Twitter.
McConnell initially offered a more measured tone Monday ahead of the vote, refraining from accusing Democrats of putting "illegal immigration" ahead of the country's needs, as he had much of the weekend. But after the vote, he resumed blasting Democrats for shutting down the government over the issue.
Even so, he promised to give immigration a fair airing. "Let me be clear: This immigration debate will have a level playing field at the outset, and an amendment process that is fair to all sides," he said.
Senators said the shift in the GOP leader's tone and language — specifically McConnell's promise that immigration legislation would be considered in an open process — was a move in their direction that allowed them to vote yes.
"What changed overnight for me was Leader McConnell's statement this morning," said Sen. Angus King, the Maine independent who caucuses with Democrats. "He was committed to bringing a bill to the floor in a fair, level playing field setting."
The success of the Common Sense caucus may signal the rising clout of moderate lawmakers willing to withhold their votes to broker compromise. But a similar bipartisan push after the failure of the GOP effort to repeal Obamacare last year fizzled without much success.
For many, the gatherings in the office of Sen. Susan Collins (R-Maine) offered a glimpse of how a new Senate could break from the hyper-partisanship in Washington to govern.
"Susan's office is Switzerland," said Sen. Lindsey Graham (R-S.C.), who helped organize the sessions.
The group included red state Democrats, Sens. Joe Manchin III (D-Va.), Heidi Heitkamp (D-N.D.) and Joe Donnelly (D-Ind.) and others like Sens. Bill Nelson (D-Fla.) and Amy Klobuchar (D-Minn.) — all up for reelection in fall.
Among the Republicans were known deal-makers, including the Tennesseans, Sens. Lamar Alexander and Bob Corker, and Arizona Sen. Jeff Flake, but also newer brokers, including Sen. Cory Gardner (R-Colo.), who is running the GOP's reelection committee, and Sen. Mike Rounds (R-S.D.), a former governor.
Trump invited two of them, Manchin and Sen. Doug Jones, the newly elected Democrat from Alabama, to the White House later Monday, thanking them for their work in a conversation that moved from immigration to an infrastructure deal.
In an unusual display of comity, the caucus met publicly off the Senate floor after Monday's vote for a celebratory huddle — Republicans and Democrats.
"If we can make a lasting difference in how the Senate of the United States works, we can get it back to working," said Sen. Chris Coons (D-Del.), who had been instrumental in the group.
The path ahead, though, remains difficult with some 17 days to reach consensus on major outstanding issues, including budget spending levels, disaster relief and opioid crisis funding.
The immigration debate will be most daunting, reminiscent of 2013 when the Senate passed an ambitious immigration overhaul, including deportation protections for about 11 million immigrants here illegally, only to see it roundly ignored by the GOP-led House as "amnesty."
Unlike the Senate, the House made no such promise Monday to consider immigration legislation.
In fact, Ryan was only able to pass an earlier version of the spending bill after an agreement with Rep. Mark Meadows (R-N.C.), the chairman of the House Freedom Caucus, to move in the other direction, by bringing up a conservative immigration bill like one Republicans proposed to reduce legal migration.
Sen. Tim Kaine (D-Va.) expressed optimism that the Senate caucus would soften bipartisan rancor. "We're going to hang together for other challenges too, because we think the engagement of this group of 30 can help the Senate be more like the Senate."
Times staff writer Sarah D. Wire in Washington contributed to this report.
6:25 p.m.: This article was updated after Trump signed the bill into law.
3:35 p.m.: This article was updated with more information about the Common Sense Caucus and reaction to the compromise.
2 p.m. : This article was updated after final Senate passage.
11:05 a.m.: This article was updated with reaction from Harris, King, Durbin and others.
9:25 a.m.: This article was updated with Schumer's comments.