A procedural vote to advance legislation passed by the House to fund the federal government through next month failed in the Senate on Friday, less than two hours before a midnight deadline passed to avert a shutdown.

The vote, which would have advanced the continuing resolution to a full Senate floor vote, failed 50-49.

"What we just witnessed on the floor was a cynical decision by Democrats shoving aside millions of Americans for political games," Senate Majority Leader Mitch McConnell said on the floor after the tally was certified.

"This government shutdown was 100 percent avoidable, completely unavoidable," the Kentucky Republican said.

"We are going to keep on voting — and the government may be heading toward shutdown but the Senate is not shutting down," he added. "We are open to talking and resolving this."

But Senate Minority Leader Chuck Schumer of New York countered that the blame rested with President Donald Trump and Republicans.

"All of these problems is because Republican leadership cannot get to 'yes' because President Trump refuses to," Schumer said.

"Mr. President if you are listening, I am urging you, please take 'yes' for an answer. The way things went today, the way you turned from a bipartisan deal, it was almost as if you were rooting for a shutdown.

"Now, we'll have one — and the blame should crash entirely on President Trump's shoulders. This will be called 'the Trump Shutdown.'"

Most Democrats rejected the continuing resolution that would have kept the government open until Feb. 16 to try to force Republicans to negotiate a permanent solution for the Deferred Action for Childhood Arrivals program.

Only five Democrats voted to advance the resolution.

They were Sens. Joe Donnelly of Indiana, Heidi Heitkamp of North Dakota, Joe Manchin of West Virginia, Claire McCaskill of Missouri and Doug Jones of Alabama.

However, four Republicans voted against the measure: Sens. Lindsey Graham of South Carolina, Rand Paul of Kentucky, Jeff Flake of Arizona and Mike Lee of Utah.

Arizona Sen. John McCain, who is battling brain cancer, was absent for the vote.

The procedural vote remained open past 11 p.m. Eastern time on Friday and was not certified until well past midnight.

It needed 60 votes to pass. Republicans hold a slim 51-49 vote in the Senate.

"Senate Democrats own the Schumer Shutdown," White House press secretary Sarah Huckabee Sanders said in a statement released just before midnight.

"Tonight, they put politics above our national security, military families, vulnerable children, and our country's ability to serve all Americans.

"We will not negotiate the status of unlawful immigrants while Democrats hold our lawful citizens hostage over their reckless demands.

"This is the behavior of obstructionist losers, not legislators," she said.

"When Democrats start paying our armed forces and first-responders we will reopen negotiations on immigration reform.

"During this politically manufactured 'Schumer Shutdown,' the president and his administration will fight for and protect the American people," Sanders said.

She earlier tweeted about the pending shutdown:

Democrats can't shut down the booming Trump economy. Are they now so desperate they'll shut down the government instead? #SchumerShutdown — Sarah Sanders (@PressSec) January 20, 2018

Hours earlier, however, Senate Democrats said after a closed-door meeting that President Trump and Schumer reached a funding deal, but that the president backed out.

"There was virtually a deal, a comprehensive agreement, between Chuck Schumer and the president, and he walked away from it after he talked to his hard right," Connecticut Sen. Richard Blumenthal told The Hill.

Trump had called the New York Democrat to a meeting in the Oval Office in a last-ditch effort to keep the government open.

A 16-day partial federal shutdown in October 2013 cost American taxpayers $1.4 billion.

Other closures occurred in 1995 and 1996.