The House of Representatives has passed a bill to fund government operations until 16 February – the first move in efforts to avert a government shutdown.
The bill must now be voted on by the Senate, where it faces an uncertain future.
The Republicans do not have enough votes. Backing from at least some Democrats is needed to pass the bill ahead of the Friday midnight deadline.
The last US shutdown happened in 2013 and lasted for 16 days.
What happens next?
A vote is now expected in the Senate at some point in the next 24 hours, but it is unclear exactly when it will take place.
Republican leaders – who need some support from the Democrats – also face resistance from their rank-and-file conservatives, who are demanding more military spending, among other things.
This so-called stopgap spending measure would keep federal agencies funded only until 16 February.
The US government is already operating on its third temporary funding extension since this fiscal year began last October.
What’s the main sticking point?
Democrats are demanding help for “Dreamers”, more than 700,000 immigrants who entered the US illegally as children.
Liberals were in uproar when Mr Trump last year ordered the Obama-era Deferred Action for Childhood Arrivals (Daca) programme, which shielded Dreamers from deportation, to end this March.
In order to convince Democratic lawmakers to back their budget bill, Republicans are offering a six-year extension of the Children’s Health Insurance Program (Chip), which benefits lower-income families.
What is Donald Trump’s position?
The president caused a minor muddle on Thursday morning when he tweeted: “CHIP should be part of a long term solution, not a 30 Day, or short term, extension!”
The president’s posting appeared to contradict Republican lawmakers’ legislative strategy.
A White House spokesperson was forced to issue a clarification later clarifying that Mr Trump did actually support the House measure.
CHIP should be part of a long term solution, not a 30 Day, or short term, extension!
— Donald J. Trump (@realDonaldTrump) January 18, 2018
End of Twitter post by @realDonaldTrump
Arriving at the Pentagon for a visit, the president told reporters the government “could very well” shut down.
Another conservative lawmaker vented his frustration with Mr Trump.
“We don’t have a reliable partner at the White House to negotiate with,” said Senator Lindsey Graham, of South Carolina, according to the Washington Post.
Throwing sand in the gears
Anthony Zurcher, BBC News, Washington
On Wednesday, the Republican Party appeared to have a plan to avoid a government shutdown or, at the very least, put Democrats in a tricky spot.
The strategy, crafted by the party’s congressional leadership, was to pass a bill that would receive enough Republican support to overcome unified Democratic resistance in the House and then jam Senate Democrats into either grudgingly voting for the bill or forcing a politically fraught shutdown over protections for undocumented immigrants.
Enter Donald Trump, tweets a-blazing. The president rejected a key piece of the party’s stopgap legislation, a long-term extension of a children’s health-insurance programme. Instead of possibly luring enough Democratic support to ease passage or forcing them to vote against a popular anti-poverty measure, Mr Trump threw sand into the gears and left the White House scrambling to walk back his tweet.
This could test just how much influence the president, with his morning tweets and contradictory public statements, has to shape the legislative process. Perhaps successful negotiations will grind on despite his actions. Or maybe the political machinery will freeze and a shutdown will commence.
Either way, and for no clear reason, the president has risked alienating congressional friends and emboldening his adversaries.
What’s at stake politically?
For Republicans, this would be the first government shutdown ever to occur when one party controls both chambers of Congress and the White House.
Senate Majority Leader Mitch McConnell emailed fellow Republicans on Thursday imploring them to vote in unison so they can blame Democrats.
Neither party wants to be held responsible for a federal shutdown with US midterms elections approaching in November.
Any backlash could also be problematic for 10 Democratic senators who are up for re-election this autumn in states that Mr Trump won in 2016.
What happens in a shutdown?
Mr Trump warned on Thursday that the consequences would be “devastating”.
But essential services would still run.
That includes national security, air traffic control, inpatient medical services, emergency outpatient medicine, disaster assistance, prisons, taxation, electricity production and the military.
National parks and monuments could face closure, which provoked an angry public reaction during the last shutdown.
The Washington Post reports the Trump administration is making contingency plans to keep the parks running if no deal is reached.
Visa and passport processing could also be delayed.