(Adds details on talks,)
By Richard Cowan, Susan Cornwell and Amanda Becker
WASHINGTON, Jan 20 (Reuters) - The U.S. government shut down at midnight on Friday after Democrats and Republicans, locked in a bitter dispute over immigration and border security, failed to agree on a last-minute deal to fund its operations.
In a late-night session, senators blocked a bill to extend government funding through Feb. 16. The bill needed 60 votes in the 100-member Senate but only 50 supported it.
Most Democrats opposed the bill because their efforts to include protections for hundreds of thousands of mostly young immigrants, known as Dreamers, were rejected by President Donald Trump and Republican leaders.
Huddled negotiations between Senate Majority Leader Mitch McConnell and Senate Democratic leader Chuck Schumer were unsuccessful, and the U.S. government technically ran out of money at midnight.
While the two men said they remained committed to reaching a deal, the shutdown formally began on Saturday, the first anniversary of President Donald Trump's inauguration.
His inability to cut a deal despite enjoying a Republican majority in both houses of Congress highlighted the deep political divide in Washington.
Until a funding deal is worked out, scores of federal agencies across the country will be unable to operate, and hundreds of thousands of "non-essential" federal workers will be put on temporary unpaid leave.
Trump immediately moved to blame Democrats.
"Tonight, they put politics above our national security, military families, vulnerable children, and our country’s ability to serve all Americans," the White House said in a statement.
It also said it would not discuss immigration until the government was up and running again.
"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."
In return, Schumer pointed the finger directly at Trump.
"It's almost as if you were rooting for a shutdown and now we'll have one and the blame should crash entirely on President Trump's shoulders," he said.
NEGOTIATE OR FIGHT?
Democratic and Republican leaders agreed to reopen negotiations on Saturday and said they were committed to getting a quick agreement.
But both sides may now be even less willing to make concessions because a political defeat on the issue could be costly, especially with the control of Congress up for grabs at midterm elections later this year.
The Republican-controlled House of Representatives passed a stopgap funding measure on Thursday. But Republicans then needed the support of at least 10 Democrats to pass the bill in the Senate. While five Democrats ended up voting for the measure, five Republicans voted against it.
Democratic leaders wanted the measure to include protections from deportation for about 700,000 undocumented immigrants who arrived in the United States as children.
Despite bipartisan negotiations, Republican leaders refused to include those protections, and neither side was willing to back down.
Trump, who had made strict measures on immigration a cornerstone of his presidential campaign, last week rejected a bipartisan proposal.
He said he wanted to include any deal for Dreamers in a bigger legislative package that also boosted funding for a wall and tighter security measures along the U.S. border with Mexico.
Schumer met with Trump on Friday afternoon and later said he had reluctantly agreed to include the border wall in the negotiations but that it still was not enough to persuade Trump to find a compromise.
McConnell said he would seek over the weekend a new funding bill that covered the federal government through to Feb. 8.
A Senate Democratic source said that was still too far out. Democrats had argued for an extension of just four or five days to force both sides into serious negotiations on the immigration issue.
Despite the formal shutdown, "essential" employees who deal with public safety and national security will keep working.
That includes more than 1.3 million people on active duty in the military who will be required to work but will not be paid until funding is renewed or handled with separate legislation.
Although past government shutdowns have done little lasting damage to the U.S. economy, they can rattle financial markets and undermine the United States' reputation abroad.
This impasse follows a months-long struggle in Congress to agree on government funding levels and protections for Dreamers, most of whom are originally from Mexico or Central America. They were given temporary legal status under the Deferred Action for Childhood Arrivals program started by former President Barack Obama.
In September, Trump announced he was ending the program and gave Congress until March 5 to come up with new legislation. Efforts to do that have so far failed so Democrats tried to get it done by linking a deal to funding of the federal government. (Additional reporting by Roberta Rampton and Jim Oliphant; Writing by Kieran Murray; Editing by Leslie Adler and Michael Perry)