Media playback is unsupported on your device Media caption Donald Trump's answerphone message blamed Democrats for the shutdown over the weekend

US President Donald Trump has hailed the end of the government shutdown as a "big win" for Republicans.

The Democratic leadership agreed to back the bill after accepting promises from Republicans for a debate later on the future of young illegal immigrants.

Mr Trump said the Democrats "caved" as he signed a bill to end the three-day shutdown.

But Senate Democratic leader Chuck Schumer said: "The great deal-making president sat on the sidelines."

Thousands of federal employees who had been placed on temporary, unpaid leave since Saturday prepared to return to work.

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

A spending bill that ended the shutdown passed the Senate by a majority of 81-18 and the House of Representatives by 266-150 on Monday.

Stocks rose as news of the agreement spread.

But the deal is not a long-term solution.

It is the fourth temporary measure since October because Capitol Hill cannot agree a longer-term budget.

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.

"I know there's great relief that this episode is coming to an end," said Speaker Paul Ryan. "But this is not a moment to pat ourselves on the back. Not even close."

What are Republicans saying?

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.

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

He then tweeted that the Democrats had "caved", adding that he looked forward to future negotiations.

The White House answerphone message over the weekend blamed Democrats for the shutdown, saying: "Unfortunately, we cannot answer your call today, because Congressional Democrats are holding government funding - including funding for our troops and other national security priorities - hostage to an unrelated immigration debate."

Media playback is unsupported on your device Media caption White House and Chuck Schumer trade barbs over shutdown

Did Democrats 'cave'?

On Twitter, "Democrats CAVED" was trending on Monday evening.

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

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

Media playback is unsupported on your device Media caption Government workers on what happens during a shutdown

Why don't shutdowns happen elsewhere?

In parliamentary systems, a government that cannot pay the bills does not last long.

In 2012, the Dutch government could not agree a budget. The prime minister resigned, elections were held, and a new government formed.

Some countries do not even need a government to function.

After its 2010 election, Belgium went more than 500 days without elected leadership, but still avoided a shutdown.

Taxes were collected, workers were paid, and a caretaker government passed a budget.

In France - a semi-presidential system - the constitution sets out what happens when a budget is not passed.

The French government shall "make available by decree the funds needed to meet commitments already voted for", the constitution says.

Really, the question is not why other countries do not shut down. It is why the US does shut down, even when there is money sloshing round the system.

That stems from the early 1980s, when US Attorney General Benjamin Civiletti strictly interpreted the 1884 Antideficiency Act in 1980.

He said, in the event of a funding gap, government agencies should suspend operations - until money was appropriated by Congress.