President Donald Trump has signed a temporary spending bill that will fund the US government until 8 February.

Earlier, the US House of Representatives followed the Senate in approving the bill that clears the way to ending a three-day government shutdown triggered by feuding over immigration policy.

The stopgap bill also reauthorises a popular children's health insurance programme.

The package cleared the House by a vote of 266 to 150, hours after Senate Democrats dropped their opposition to the plan after winning Republican assurances of a vote on immigration in the coming weeks.

Most Democratic senators had initially opposed the funding bill, demanding that the Senate also approved protections for so-called "Dreamers."

But Democratic leaders - worried about being blamed for a disruptive shutdown - accepted a Republican promise to hold a full Senate debate over immigration and the 700,000 Dreamers who were brought to the United States illegally as children.

Mr Trump took a new swipe at Democrats as he celebrated.

"I am pleased that Democrats in Congress have come to their senses," he said in a statement.

"We will make a long term deal on immigration, if and only if, it's good for the country."

Trump takes tough stance over government shutdown
Trump says Senate should change rules if shutdown continues

The shutdown, which began on Friday's first anniversary of Mr Trump’s inauguration as president, undercut his self-crafted image as a dealmaker who would repair the broken culture in Washington.

It had forced him to cancel a planned weekend trip to his Mar-a-Lago estate in Florida.

In negotiations over the shutdown, Democrats had insisted that legislation to keep the government running include protections for young undocumented immigrants known as "Dreamers."

Republicans in turn said they would not negotiate on immigration until Democrats gave them the votes needed to reopen the government.

Mr Trump said he would make a deal on immigration only if he sees it as beneficial for the country.

"We'll make a long-term deal on immigration, if and only if it is good for the country," Mr Trump said, according to a statement read to reporters by spokeswoman Sarah Sanders.

Senate Majority Leader Mitch McConnell promised to allow a fair and open immigration debate "to consider a proposal that can actually be signed into law, a bipartisan, bicameral group is already negotiating and I look forward to completion of its work".

Such a debate would occur if a deal on an immigration bill is not reached before 8 February, Mr McConnell said

Democrats want Congress to address the issue of the Dreamers and Democratic Senator Heidi Heitkamp welcomed the deal.

"You now have a commitment for a path forward for the so-called 'Dreamers’ That’s critical. We’re going to get a vote. We’re going to regular order," she said.

Both sides in Washington had tried to blame each other for the shutdown.

Democrats said Mr Trump had not only failed to bring both sides together but made a deal more difficult by changing his position on what kind of agreement on immigration he would accept.

Mr Trump and Republicans accused Democrats of putting the interests of illegal immigrants ahead of US military personnel and government workers.