Republicans and Democrats sealed a deal on Capitol Hill to reopen the federal government.

US federal workers prepared to return to work Tuesday after Congress ended a three-day government shutdown, with President Donald Trump claiming victory in his standoff with Democrats.

The House voted 266 to 150 to extend federal funding for another three weeks, hours after Senate Democrats dropped their opposition to the plan after winning Republican assurances of a vote on immigration in the coming weeks.

Trump signed the measure into law Monday night and government operations were essentially to return to normal on Tuesday.

"I know there's great relief that this episode is coming to an end," House Speaker Paul Ryan told colleagues. "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.

The shutdown began at midnight Friday and thus affected only one regular workday -- Monday -- but it made both parties look bad. If it had continued, hundreds of thousands of federal employees would have been furloughed.

Democrats decided to end the 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. They had been protected from deportation under an Obama-era program known as DACA, which Trumps wants to end.

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.

Earlier, 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 in a statement.

And in a tweet late Monday, he again cried victory over the Democrats.

"Big win for Republicans as Democrats cave on Shutdown," he wrote on Twitter.

Trump added: "Now I want a big win for everyone, including Republicans, Democrats and DACA, but especially for our Great Military and Border Security. Should be able to get there. See you at the negotiating table!"

In a sign of the poisoned politics of Washington, when top Senate Democrat Chuck Schumer announced his party would vote with Republicans to end the shutdown he also pilloried Trump.

"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.

- High-profile holdouts -

Schumer told Senate Majority Leader Mitch McConnell that he expected Republicans to make good on a pledge to address Democrats' concerns over the Deferred Action on Child Arrivals (DACA) program. This 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 on Monday.

Source: AFP