The US government partial shutdown is ending after Republicans and Democrats voted for a temporary funding bill.
The Democratic leadership agreed to back the bill after accepting promises from Republicans for a debate later on the future of young illegal immigrants.
President Donald Trump, who signed the bill on Monday evening, took a swipe at Democrats.
It is the fourth temporary measure since October because Capitol Hill cannot agree a longer-term budget.
The spending bill passed the Senate by 81-18 and the House of Representatives by 266-150 earlier on Monday.
The so-called continuing resolution keeps the government funded until 8 February in the hope that Congress can reach a longer-term budget agreement in the meantime.
Thousands of federal employees who had been placed on temporary, unpaid leave since Saturday breathed a sigh of relief.
“It was essentially a lunch break,” Tom Chapel, a scientist at the Centers for Disease Control and Prevention in Atlanta, Georgia, told Reuters news agency.
Republican Senate leader Mitch McConnell said his party had “come to an arrangement” to negotiate on the Democrats’ calls for an immigration deal.
Democrats want protections from deportation for so-called Dreamers, more than 700,000 young immigrants brought to the US as children.
But Republicans had insisted no agreement was possible while federal government services were closed.
President Trump, a Republican, said in a statement: “I am pleased that Democrats in Congress have come to their senses.
“We will make a long-term deal on immigration if, and only if, it is good for our country.”
Democrats voiced scepticism of Mr McConnell’s promise and some liberal groups are infuriated by the agreement to reopen the government.
Possible Democratic 2020 presidential candidates in the Senate – Elizabeth Warren, Kirsten Gillibrand, Cory Booker, Bernie Sanders and Kamala Harris – all voted against Monday’s bill.
Senator Harris, of California, said it would be “foolhardy” to trust Mr McConnell’s promise to take up an immigration bill in the coming weeks.
Another California senator, Dianne Feinstein, told The Hill, a political news outlet, she was “very disappointed” in the deal because there’s no guarantee that Republicans would help Dreamers.
Democratic congressman Luis Gutierrez slammed his own party’s senators after the vote saying: “They caved. They blinked. That’s what they do.”
On Twitter, “Democrats CAVED” was trending on Monday evening.
Senate Democratic leader Chuck Schumer accused President Trump of failing to help reach a deal.
“The great deal-making president sat on the sidelines,” he said.
But many have expressed dissatisfaction with Mr Schumer’s handling of the shutdown, which began on midnight on Friday.
“It’s Schumer’s job to lead and keep his caucus together to fight for progressive values, and he didn’t do it,” said Ezra Levin, co-executive director of the activist group Indivisible.
Stephanie Taylor, of the Progressive Change Campaign Committee, said: “Today’s cave by Senate Democrats – led by weak-kneed, right-of-centre Democrats – is why people don’t believe the Democratic Party stands for anything.”
The shutdown is over, but the immigration and budget battles rage on. Both sides will try to claim victory, with varying degrees of success.
Republicans are thrilled that – unlike past shutdown fights – they emerged relatively unscathed. Senate Majority Leader Mitch McConnell promised an open debate and vote on protections for so-called Dreamers, but in reality that could go by the wayside if, three weeks hence, Democrats force another shutdown.
Democrats, on the other hand, can claim that they took a confrontational stand – at least for a few days – on an issue dear to their base’s heart. Whether that’s enough to satisfy the progressive hard-liners and grassroots activists is in doubt, however. A key tell is that nearly every 2020 presidential hopeful among their number voted against re-opening. For them, Mr McConnell’s guarantees are written in sand.
Meanwhile, Donald Trump was largely sidelined through the process. Democrats, and even some Republicans, complained he was impossible to pin down and unclear about his priorities. Still, a few days out of the spotlight may not have been all bad.
The American public will probably forget this long-weekend shutdown before too long. The next fight, looming only weeks away, might be different.