The White House says President Donald Trump has signed a bill reopening the government, ending a display of partisan dysfunction after Democrats reluctantly voted to temporarily pay for resumed operations.
The shutdown took effect on Saturday on the one-year anniversary of the president's inauguration, but the White House maintains that Trump came out the winner in the GOP's standoff with Democrats.
The White House argues Democrats "caved" after Trump refused to negotiate with them on immigration policy until the government reopened.
Democrats had been holding out for a firmer commitment to provide protections for some 700,000 younger immigrants brought illegally to the US as children.
The Senate voted 266 to 150 to extend federal funding, hours after Senate Democrats dropped their opposition to the plan after winning Republican assurances of a vote on immigration in the coming weeks.
"I know there's great relief that this episode is coming to an end," House Speaker Paul Ryan told colleagues on the House floor. "But this is not a moment to pat ourselves on the back. Not even close."
The stalemate consumed Washington for the better part of a week, as lawmakers and the White House feuded over immigration policy and the nation's two main political parties exchanged bitter barbs before finally reaching a deal.
"I am pleased Democrats in Congress have come to their senses," Trump said in a defiant statement, as lawmakers moved to get hundreds of thousands of federal government employees back to work.
Government operations are expected to essentially returning to normal on Tuesday.
Democrats decided to end the three-day shutdown after making progress with ruling Republicans toward securing the fate of hundreds of thousands of so-called "Dreamers" brought to America as children, many of them illegally.
With Democratic support, a bill keeping the government funded until February 8 easily passed the Senate, where different versions of the funding had languished for days.
Word of the compromise deal struck in Washington sent US stocks surging to new highs.
But the White House appeared in no mood for bipartisanship or magnanimity after a shutdown that overshadowed Trump's first anniversary in office.
Trump moved to undercut Democrats, saying he would only accept a comprehensive immigration reform -- one that notably addresses his demands for a border wall with Mexico as well as the fate of the "Dreamers."
"We will make a long-term deal on immigration if, and only if, it is good for our country," he said.
Top Senate Democrat Chuck Schumer earlier announced his party would vote with Republicans to end the shutdown, but in a sign of the poisoned politics of Washington he pilloried Trump in the process.
"The White House refused to engage in negotiations over the weekend. The great deal-making president sat on the sidelines," Schumer said.
Trump spent the weekend stewing at the White House when he had planned to be among friends and family at his home in Mar-a-Lago, Florida for his anniversary bash.
And with the fundamental row on immigration and funding of Trump's border wall unresolved, Republicans and Democrats may very well find themselves back in a similar stalemate come February 9.
Schumer told Senate Majority Leader Mitch McConnell that he expected Republicans to make good on a pledge to address Democrat concerns over the Deferred Action on Child Arrivals (DACA) program that shields immigrants brought to the country as children from deportation, but expires on March 5.
There are an estimated 700,000 "Dreamers" whose fates are up in the air.
"If he does not, of course, and I expect he will, he will have breached the trust of not only the Democratic senators but members of his own party as well," Schumer said.
Trump has staked his political fortunes on taking a hard line on immigrants, painting them as criminals and scroungers.
Senator Tim Kaine summed up the view of the more optimistic Democrats: "We got a commitment that I feel very, very good about."
But if no progress is made on an immigration bill, Molly Reynolds of the Brookings Institution warned, "Democrats still have the ability to potentially force another shutdown over the issue."
The House is under no obligation to pass any Senate bill generated as a result of McConnell's pledge to cooperate with Democrats -- although Speaker Ryan did say his chamber needs to "move forward in good faith" on DACA and immigration.
Notably, many of the Senate Democrats who voted against the funding agreement included a litany of potential 2020 presidential candidates, including Kamala Harris, Bernie Sanders, Kirsten Gillibrand and Elizabeth Warren.
Dealmaker on sidelines
Ahead of the deal, Trump had goaded Democrats from the sidelines, accusing them of shutting down the government to win concessions on immigration, in service of "their far left base."
There have been four government shutdowns since 1990. During the last one, in October 2013, more than 800,000 government workers were put on temporary leave.
Essential federal services and the military were operational Monday, but even active-duty troops will not be paid until a deal is formally sealed.