US President Donald Trump has threatened a "very long" government shutdown if opposition Democrats refuse to approve funds for more border security and a wall on the US border with Mexico.

"Shutdown today if Democrats do not vote for Border Security!," Mr Trump said in one of a string of tweets on the subject.

"If the Dems vote no, there will be a shutdown that will last for a very long time. People don't want Open Borders and Crime!"

Mr Trump and congressional Democrats remain far apart as a midnight deadline looms to approve funds to keep the US government up and running.

Without an agreement key agencies will close and many workers will be furloughed right before Christmas without a pay cheque.

Mr Trump appeared to harden his demand for $5 billion (€4.4bn) in funding for the wall on the US-Mexico border, a pet project he has fought for since he began campaigning for president in 2015.

"Even President Ronald Reagan tried for 8 years to build a Border Wall, or Fence, and was unable to do so. Others also have tried. We will get it done, one way or the other!" Mr Trump wrote.

According to the president, Democrats are trying to belittle the concept of a wall by calling it old fashioned.

Republican leaders had planned to pass a so-called continuing resolution (CR) that would fully fund government until 8 February, to allow time for debate about issues including border security.

But with ultra-conservative lawmakers and media personalities effectively demanding that the president stick to his campaign promises, Mr Trump doubled down.

"I've made my position very clear. Any measure that funds the government has to include border security," he said at a White House event yesterday.

"Walls work, whether we like it or not," he added. "They work better than anything."

Democrats have refused to budge, saying they will not support a spending measure that funds Mr Trump's wall.

"That's a non-starter," said top House Democrat Nancy Pelosi. "I think they know that."

Republicans nevertheless soldiered on, crafting a new measure that would appease the president's demands. It includes $5.7 billion in border wall funding, and $7.8 billion in disaster relief.

The bill passed the House with no Democratic support. It will be dead on arrival in the 100-member Senate, where bills need 60 votes to advance and Republicans control 51 seats.

Senate Democrats were united in opposition as the likely showdown today in that chamber loomed. Many senators from both parties have already left Washington for the holidays.

"President Trump is plunging the country into chaos," warned Senate Minority Leader Chuck Schumer, citing shutdown fears, fresh economic woes, and the shock revelation that Secretary of Defense Jim Mattis, a stabilising force in Trump's administration, was stepping down.

"The bottom line is simple," he added. "The Trump temper tantrum may produce a government shutdown. It will not get him his wall."

Fears of a shutdown - which could send thousands of federal employees home without pay just before Christmas - helped send US stocks tumbling, with the Dow closing down 2.0%.

Mr Trump had backed off his shutdown threat earlier this week, but revived it again as he accused Democrats of "putting politics over country" by not supporting a wall, which he insists will curb illegal immigration.

His move may have been influenced by members of the House Freedom caucus, some of whom have publicly called on the Republican president to stick to his guns on wall funding.

"Mr President, we'll back you up," caucus chairman Mark Meadows said on the House floor late Wednesday. "If you veto this bill (with no wall funding), we'll be there."

Ms Pelosi, the likely new speaker of the House when Democrats reclaim the majority on 3 January, meanwhile accused Republicans of having a "meltdown" over whether to pass the stopgap measure or force a shutdown.

The US government endured two brief shutdowns in early 2018.

A far more crippling shutdown in 2013 lasted 16 days, with about 800,000 federal workers furloughed amid a fight over funding Barack Obama's health care reforms.