The US government is approaching a federal shutdown after the Senate failed to agree on a new budget.
It was unclear which way the vote would go as the midnight deadline approached, with Republicans and Democrats split on key issues.
Despite last minute bipartisan meetings, the bill to fund the government until 16 February did not receive the required 60 votes.
The last US shutdown happened in 2013 and lasted for 16 days.
The House of Representatives voted 230-197 on Thursday night to extend funding until next month, but the measure failed to pass the Senate.
Many government offices will close unless a compromise is found before the midnight deadline.
If the shutdown goes ahead essential services will still run. That includes national security, post, air traffic control, inpatient medical services, emergency outpatient medicine, disaster assistance, prisons, taxation and electricity production.
National parks and monuments could face closure, which provoked an angry public reaction during the last shutdown.
In the hours before the vote, President Donald Trump sounded pessimistic, tweeting that it was "not looking good for our great Military or Safety & Security on the very dangerous Southern Border".
He had invited Democratic Senate leader Chuck Schumer, a fellow New Yorker, to the White House for last-ditch talks but they failed to find sufficient common ground.
Emerging about an hour later, Mr Schumer told reporters "some progress" had been made, but a "good number of disagreements" remained, including a difference in opinion regarding the Democrats' desire to extend talks for another five days.
What's the problem?
The main bone of contention has been Democrats' demands for more than 700,000 undocumented immigrants who entered the US as children to be protected from deportation.
These "Dreamers", as they are known, were granted temporary legal status under a programme established by former President Barack Obama.
In September, Mr Trump announced he was ending the programme and allowing Congress until March to come up with a replacement.
The Republican president and congressional conservatives have been using the issue as a bargaining chip in an attempt to wring concessions from Democrats.
Mr Trump wants funding for tough new border controls, including his proposed US-Mexico wall.
Republicans have added to the bill a sweetener in the form of a six-year extension to a health insurance programme for children in lower-income families.
They are essentially daring Democrats to vote against a measure that has been a longstanding liberal priority.
But Democrats say they want this programme extended permanently.
The legislative negotiations went up in flames last week after Mr Trump allegedly complained the US was letting in immigrants from certain "shithole countries".
What could be the political fallout?
The blame game is already in full swing with neither party wishing to be held accountable for closing the government as midterm elections loom in November.
This would be the first shutdown while one party is in control of both chambers of Congress and the White House, which could be politically embarrassing for Republicans.
A new Washington Post-ABC poll suggests that by a 20-point margin more Americans blame President Trump and his party for the imbroglio, rather than Democrats.
But a shutdown would also be problematic for 10 Democratic senators who are up for re-election this year in states won by Mr Trump.
They would face voters this autumn amid a hail of attack ads claiming they closed the US government to help illegal immigrants.
Be careful what you wish for, Mr Trump
In a late-night speech on the Senate floor, top Republican Mitch McConnell accused Democrats of trying to "hold the entire country hostage".
Mindful of the risks, Democrats have shifted their messaging in recent days to say their opposition is about much more than just immigration.
Democrats hope to make it instead about the president and Republicans' ability to govern.
Tennessee Democrat Steve Cohen tweeted of Mr Trump: "This man doesn't comprehend work ethic, the office of President, or duty to the country. He understands golf, ice cream, and Big Macs!"
What happens in a shutdown?
US Defence Secretary Jim Mattis said that over 50% of his department would not go to work, and some maintenance, training and intelligence operations would come to a halt.
"We do a lot of intelligence operations around the world and they cost money, these obviously would stop," Mr Mattis said when asked about the impending shutdown, "it's got a huge morale impact."
The Trump administration is reportedly making contingency plans to keep the parks running if no deal is reached.
Visa and passport processing could also be delayed.
Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://www.youtube.com/watch?v=0myyuxF7L1o