The US government was headed toward a partial shutdown at midnight on Friday after President Donald Trump's fellow Republicans in the Senate failed to muster the votes needed to approve $5 billion (Dh23 billion) he has demanded for a border wall fiercely opposed by Democrats.
Mr Trump said the impending shutdown of key parts of the federal government could last "a very long time," and he sought to blame Democrats. They, in turn, put the blame squarely on him for his Thursday demand for wall funding after earlier backing bipartisan short-term government funding legislation passed by the Senate on Wednesday without any such money.
The impending shutdown was the latest evidence of dysfunction in Washington and might not bode well for next year, when Democrats will have a stronger hand as they take control of the House of Representatives.
"President Trump has thrown a temper tantrum and now has us careening towards a 'Trump shutdown' over Christmas," Senate Democratic Leader Chuck Schumer said on the Senate floor.
"You're not getting the wall today, next week or on January 3rd, when Democrats take control of the House," Mr Schumer added.
Hours before the deadline, lawmakers met with Vice President Mike Pence and other White House officials in a last-ditch effort to find a compromise government funding bill acceptable to both political parties and Mr Trump. There was little indication any such agreement was imminent, but senators said talks would continue.
Congressional funding for about one-quarter of the federal government's programs expires at midnight (9am AD), and a shutdown would ensue if Congress, controlled by Trump's fellow Republicans, does not pass legislation to provide money to keep the agencies open.
Before meeting with Senate Republicans at the White House, Mr Trump wrote on Twitter that "Democrats now own the shutdown," despite having said last week that he would be "proud" to close the federal government over the issue of border security and "I'll be the one to shut it down."
The House adjourned just before 7pm without approving government funding, all but ensuring a government shutdown.
Negotiators were discussing $1.6 billion for a range of border security measures - not specifically for a wall - and retaining financial assistance for areas hit by natural disasters that was added by the House, according to a Republican Senate aide.
That $1.6 billion would only be $300 million more than the amount the Senate approved in a temporary funding bill it passed late on Wednesday.
"It's possible that we'll have a shutdown. I would say the chances are probably very good," Mr Trump said at the White House.
"We're going to get a wall," Mr Trump added.
A wall along the US-Mexican border to combat illegal immigration and drug trafficking was a key Trump campaign promise in the 2016 election, when he said it would be paid for by Mexico, and he sees it as a winning issue for his 2020 re-election campaign. Democrats oppose the wall, calling it unnecessary and ineffective.
With Mr Pence casting a tie-breaking vote, the Senate, where Republicans have a 51-49 majority, passed a procedural measure on Friday related to legislation approved by the House on Thursday with the wall money that Trump wanted. But Senate Republicans came up short of the votes needed to pass the wall funding.
Senate Majority Leader Mitch McConnell said the procedural vote merely ensured the White House and Democrats could keep discussing a potential compromise to avert a shutdown. Mr Schumer said he was willing to continue talks. A Schumer spokesman said the senator met with Pence, Trump's new chief of staff, Mick Mulvaney, and Trump's son-in-law and adviser Jared Kushner.
"There are some people on the White House team who think this can be done in hours. There are others that think it takes 24 (hours)," Republican Senator Bob Corker said.
Republican Senators Lamar Alexander and Marco Rubio expressed frustration with what they said was a shifting position by the White House. Mr Rubio said that earlier in the week the Republicans went with their funding bill, which included $1.3bn for general border security but nothing specifically for a wall, because Mr Pence had told them the White House was open to such a proposal.
"We had a reasonable path and there was every indication from the president that he would sign it," Alexander said.
In a series of early-morning tweets on Friday, Mr Trump called on Mr McConnell to use the "nuclear option" to allow a Senate vote on legislation with a simple majority, rather than the standard "supermajority" of 60 votes. But there was not enough support among Republican senators to do so.
Three-quarters of government programs are fully funded through to the end of the federal fiscal year next September 30, including those in the Defence Department, Labour Department and Health and Human Services. Funding for other agencies, including the Department of Homeland Security, Justice Department and Agriculture Department, was set to expire at midnight on Friday.
A partial government shutdown could begin with affected agencies limiting staff to those deemed "essential" to public safety. Such critical workers, including U.S. border agents, and nonessential employees would not get paid until the dispute ends. National parks also would close unless the government declares them essential.
More than half of the 1,700 people who work for the executive office of the president would be furloughed.