(Updates with details of negotiations)
WASHINGTON, Jan 19 (Reuters) - U.S. lawmakers raced against the clock to avert a federal government shutdown on Friday but it was not clear if hectic negotiations would bring a deal before a midnight deadline.
The vast majority of Democratic senators have said they would not support the bill unless it includes protections for hundreds of thousands of young illegal immigrants. Republicans have so far refused.
Senate Majority Leader Mitch McConnell scheduled a key procedural vote on the bill for 10 p.m. (0300 GMT) and Democratic and Republican lawmakers huddled to see if either side was ready to back down or if they could find a compromise.
Even as they talked, both sides were blaming each other for the impasse. Without a late deal, the shutdown would begin right after midnight, on the first anniversary of President Donald Trump's inauguration.
Trump met with Senate Democratic leader Chuck Schumer at the White House earlier on Friday in search of a breakthrough.
"Making progress - four week extension would be best," Trump said in a tweet.
Schumer agreed that some progress had been made but said there were still a number of disagreements.
The Republican-controlled House of Representatives approved a stopgap spending bill late on Thursday that would fund the federal government through Feb. 16. But it needs the support of at least 10 Democrats to pass the Senate.
White House budget director Mick Mulvaney said he expected an agreement would be reached in the next 24 hours, indicating the government would shut down at midnight but reopen again at some point over the weekend.
Past government shutdowns have done little lasting damage to the U.S. economy, but put hundreds of thousands of "non-essential" federal workers on temporary unpaid leave. Shutdowns can also rattle financial markets.
"Essential" employees who deal with public safety and national security would keep working under a shutdown. That includes more than 1.3 million people on active duty in the military who would be required to keep working and would not be paid until the shutdown ends.
The White House said on Friday night that it would keep national parks open, with rangers and security guards on duty as usual something the administration of President Barack Obama ruled out during the last significant shutdown in 2013.
During that impasse, government funding lapsed for 16 full days and about 800,000 federal workers were put on temporary leave.
This week's showdown follows a months-long struggle in Congress to agree on government funding levels and the immigration issue.
The federal government is operating on a third temporary funding measure since the current fiscal year began in October.
PROTECTION FOR "DREAMERS"
Democrats have demanded the bill include protections from deportation for about 700,000 illegal immigrants who were brought into the United States as children.
Known as "Dreamers" and largely from Mexico and Central America, these immigrants were given temporary legal status under the Deferred Action for Childhood Arrivals (DACA) program started by Obama. In September, Trump announced he was ending the program and giving Congress until March 5 to come up with a legislative replacement.
Trump pointed the finger at his political rivals earlier on Friday.
"Democrats are needed if it is to pass in the Senate - but they want illegal immigration and weak borders. Shutdown coming?" he said.
Democrats say the search for a deal has been hurt by Trump's sending contradictory messages about what kind of bipartisan immigration proposal he would accept.
Republican Senator Tom Cotton said he was willing to provide protection to DACA recipients in future negotiations.
"We have another six weeks to solve that problem. It doesn't really involve government funding," Cotton told Fox News. "We should take those two issues up in sequence."
Republicans have a 51-49 majority in the Senate. With Senator John McCain undergoing cancer treatment at home in Arizona, Republicans need at least 10 Democrats to reach the 60 votes required to pass a spending bill.
There were some dissident voices inside both parties.
At least three Republican senators have said they will not back the resolution in its current form. On the other side, at least three Democrats who are up for re-election this year in states Trump won in the 2016 presidential election said they would support the bill.
Some senators raised the possibility of merely approving enough new federal funds for a few days, as a tactic to put pressure on negotiators to then cut deals on immigration, defense spending and non-defense funding by next week.
But a White House aide said late on Friday that Trump would not support a deal that keeps the government open for just four or five days.
McConnell also shot down the idea. "Let's fund the government for a full month so we can actually get something done," he said. (Reporting by Richard Cowan and Susan Cornwell; Additional reporting by Roberta Rampton, Steve Holland, Lisa Lambert, Blake Brittain and Amanda Becker; Writing by John Whitesides and Kieran Murray; Editing by Leslie Adler)