The House passed a short-term extension of government funding late Thursday after Republican leaders, with help from President Trump, cobbled together enough GOP votes to overcome an internal revolt.

Still, the possibility of a federal shutdown moved closer to a certainty after Senate Democrats rallied against the GOP proposal, announcing they would not lend their votes to a bill that did not reflect their priorities on immigration, government spending and other issues.

By Thursday evening, nine Senate Democrats who had voted for a prior spending measure in December said they would not support the latest proposed four-week extension, joining 30 other Democrats and at least two Senate Republicans — and leaving the bill short of the 60 votes needed to advance.

As a result, Republican leaders — long on the defensive against claims that they were failing to govern — appeared emboldened as they sought to cast the Democrats as the obstacle to a compromise to keep critical government functions operating.

"My Democratic colleagues' demands on illegal immigration, at the behest of their far-left base, have crowded out all other important business," Senate Majority Leader Mitch McConnell (R-Ky.) said Thursday night. "And now they are threatening to crowd out the needs of veterans, military families, opioid treatment centers and every other American who relies on the federal government — all over illegal immigration."

Senators of both parties voted to open debate on the House bill late Thursday, but Senate Minority Leader Charles E. Schumer (D-N.Y.) said Democrats remained opposed to the measure and proposed an spending extension that would last just a few days to allow talks on a broader agreement to continue.

"We have to sit down together and solve this, with the president or without," he said.

Republican leaders rejected that suggestion. They did not lay out a Plan B to pursue if the House bill is ultimately rejected, except to finger Democrats for a shutdown.

"I ask the American people to understand this: The only people in the way of keeping the government open are Senate Democrats," House Speaker Paul D. Ryan (R-Wis.) said Thursday night. "Whether there is a government shutdown or not is entirely up to them."

Senate GOP leaders prepared to force Democrats into a series of uncomfortable votes, aimed at splitting their ranks by pitting moderates from states that Trump won against party leaders and the handful of outspoken liberals considering a run for the presidency.

For one, Republicans attached a long-term extension of the Children's Health Insurance Program and delays to several unpopular health-care taxes. The bill does not include protections for "dreamers," immigrants brought to the United States illegally as children or who overstayed their visas as children, a top Democratic priority.

That represented an election-year bid by the GOP to cast the spending vote as, in part, a choice between poor children and undocumented immigrants. Ryan, McConnell, and other Republicans also sought to highlight the potential erosion to military readiness that could result from a shutdown.

Emboldened Democratic leaders, meanwhile, rallied lawmakers for a showdown on what they believe is favorable ground, fighting on behalf of popular policies against an unpopular president who has had a brutal week of news coverage. As Thursday wore on, undecided senators steadily stepped forward to say that they would oppose the Republican measure — risking GOP political attacks and angry constituents.

Sens. Tim Kaine and Mark R. Warner, Virginia Democrats who represent tens of thousands of federal employees who stand to be furloughed during a shutdown, said they could not vote for a bill that did not include relief for dreamers, disaster funding, opioid treatment funding and more — echoing the demands of Democratic leaders.

"These issues are not going away and need to be addressed immediately," they said in a joint statement that also criticized Trump: "He has to decide whether he wants to be President and engage in necessary compromise, or continue offering commentary from the sidelines."

Trump fired back at Democrats during a trip to Coraopolis, Pa., saying that they're pushing for a shutdown to distract voters from the GOP's recent tax legislation. "That is not a good subject for them, the tax cuts," Trump said.

The late-night showdown capped a long, tense day on Capitol Hill that began with a flurry of tweets from Trump that doubled down on his demands for an expensive border wall and accused Democrats of snubbing the military. Another tweet, however, seemed to upend the Republican strategy for avoiding a shutdown and contradict his administration's stated policy position — suggesting that the children's health program ought not to be attached to a temporary spending bill.

Republican lawmakers and aides, who were already pressed to secure enough GOP votes to get the bill through the House, scrambled to decipher Trump's intentions. Much as he had to do a week ago after Trump tweeted about an intelligence bill, Ryan got on the phone with the president to clarify matters, and hours later, the White House confirmed that Trump indeed supported the bill.

The tweets inflamed frustrations in both parties over what they characterized as an all-too-often uncooperative president.

"We don't have a reliable partner at the White House to negotiate with," Sen. Lindsey O. Graham (R-S.C.) said. "This has turned into an s-show for no good reason."

Schumer called Trump and his administration "agents of chaos" who have foiled attempts to reach a bipartisan agreement on immigration, which remained the most salient sticking point Thursday.

"The one thing standing in our way is the unrelenting flow of chaos from the other end of Pennsylvania Avenue," Schumer said. "It has reduced the Republicans to shambles. We barely know who to negotiate with."

Meanwhile, Republican leaders were having trouble smoothing out a wrinkle in their plans to blame a shutdown on Democrats: Hard-line House conservatives demanded concessions in return for their votes, casting doubt on whether the funding patch would even reach the Senate.

All but a few House Democrats said they would not support the bill without an immigration or long-term budget deal.

"If we can't agree, your party has the majority in the House and the Senate to pass your own funding resolution. But that will be a bill we cannot support," 171 of 193 House Democrats wrote in a letter to Ryan on Thursday.

While Ryan worked the House floor during an afternoon vote series, trying to lock down votes for the patch, leaders of the hard-right House Freedom Caucus tried to persuade Republicans to withhold their votes.

"I promise you he doesn't have the votes," said Rep. Mark Meadows (R-N.C.), heading to a closed-door Freedom Caucus meeting, where Trump called in to try to win over restive conservatives.

Meadows and Rep. Jim Jordan (R-Ohio) then went into Ryan's office, where they hashed out a deal with Republican leaders to secure future votes on measures that would increase defense spending and tighten immigration laws. With that accord in place, the House voted 230 to 197 to pass the legislation. Only six Democrats broke ranks to support it.

Senators strategized through the day on how to turn the clash to their advantage — retreating into party lunches to plan for a showdown that could stretch into the weekend or beyond.

Reflecting the election-year stakes, aides to McConnell told senior staffers that he was intent on muscling the bill through the upper chamber and putting pressure on Democrats to vote for it, according to a person familiar with the meeting.

"Let's bring the House bill over and have a quick vote and make the Democrats up in 2018 figure out what they want to do," the person said of the meeting.

Ten Democrats are seeking reelection in states that voted for Trump in 2016, and Republicans believe that they can force them into tough votes that would either force a rift in the Democratic ranks or provide powerful fodder for political attacks later in the year.

Democrats expressed confidence that they would come out on top in the public-opinion battle over who would shoulder the blame for a shutdown — citing broad public sympathy for dreamers, political winds blowing against Republicans and Trump's approach to bipartisan negotiations.

Last week, he rejected an immigration compromise in an Oval Office meeting where he referred to poor nations as "shithole countries," driving days of public criticism.

"I think their argument falls apart because of last week in the Oval Office, because of their inability to even get a [temporary funding bill] out of the House in a timely fashion without making concessions to the Freedom Caucus," said Sen. Brian Schatz (D-Hawaii).

Even as a shutdown grew more likely, some senators hoped to find a path away from it. Some senators discussed the possibility of passing one- or two-day extensions of government funding to avoid a shutdown while lawmakers continue to negotiate.

But Republican leaders did not immediately embrace the idea, and it was unclear how it would work for the House, which is scheduled to be out of session next week.

Top leaders of both parties continued meeting Thursday to seek an immigration compromise, but no agreement appeared to be in sight. Senate Majority Whip John Cornyn (R-Tex.), leaving a meeting with other deputy leaders, rejected the idea that a deal to protect dreamers could be concluded by Friday evening at midnight. "No, no," he told reporters.

The government shutdown causing employee furloughs has never occurred under unified party control of Congress and the White House.

The Trump administration is drawing up plans to keep national parks and monuments open despite a shutdown as a way to blunt public anger, and while the military would not cease to operate, troops would not be paid unless Congress specifically authorizes it.

The last shutdown, in 2013, lasted for 16 days as Republicans tried unsuccessfully to force changes to the Affordable Care Act. On Jan. 30, Trump is scheduled to deliver his State of the Union address.

Mike DeBonisMike DeBonis covers Congress, with a focus on the House, for The Washington Post. He previously covered D.C. politics and government from 2007 to 2015. Follow

Ed O'KeefeEd O’Keefe covered Congress and national politics for The Washington Post from 2008 to 2018. He has also covered federal agencies and federal employees in the Washington area, the war in Iraq, and the 2016 presidential campaigns of Jeb Bush and Marco Rubio. Follow

Erica WernerErica Werner has worked at The Washington Post since 2017, covering Congress with a focus on economic policy. Previously, she worked at the Associated Press for more than 17 years. Follow