Congress passed a stopgap spending bill Thursday, averting a partial government shutdown at midnight Friday but pushing into January showdowns on spending, immigration, health care and national security.

Among the issues still to be resolved is federal aid for victims of recent hurricanes and wildfires. The House on Thursday passed a separate $81 billion disaster relief bill, but the Senate did not immediately take it up amid Democratic objections.

The stopgap extends federal funding through Jan. 19 and provides temporary extensions of the Children’s Health Insurance Program, which has languished politically since it expired in October, a veterans health-care program and a warrantless surveillance program set to expire Jan. 1.

“It is essential that Congress maintain government programs and services for our nation’s stability, the stability of our economy, and for the security and well-being of the American people,” House Appropriations Committee Chairman Rodney Frelinghuysen (R-N.J.) said Friday on the House floor, urging lawmakers to support the stopgap.

It passed the House 231 to 188 and cleared the Senate 66 to 32. Thursday’s congressional votes are expected to be the last of 2017.

President Trump with Senate Majority Leader Mitch McConnell R-Ky.), Vice President Pence, House Speaker Paul D. Ryan R-Wis.) and Sen. Tim Scott R-S.C.) on the South Lawn of the White House in Washington on Wednesday. (Jabin Botsford/The Washington Post)

The votes came after House GOP leaders scrambled Wednesday and Thursday to gather votes to keep the government open, seeking to defuse intraparty squabbling that erupted just hours after Republicans passed a landmark tax overhaul Wednesday.

Between assurances from House Speaker Paul D. Ryan (R-Wis.), pressure from President Trump to avoid a shutdown and the impending holidays, most GOP lawmakers agreed to set aside their misgivings.

“The fact of the matter is, it’s Christmas, and we don’t need to be shutting the government down. I mean, that’s a horrible optic,” said Rep. Roger Williams (R-Tex.), who said he was dismayed by the lack of long-term military funding but supported the stopgap.

But some frustrations lingered. While many House Republicans burst into applause after passing the short-term spending measure, not everyone saw cause for celebration.

“That we’re clapping for a three-week CR just basically shows we can’t do appropriations, we can’t take care of our constituents back home, we just have to punt for three more weeks so we can leave for Christmas,” said Rep. Thomas J. Rooney (R-Fla.), a member of the Appropriations Committee who has pushed for federal aid for citrus growers devastated by hurricanes. “For some reason, that justifies applause. I don’t get it. I don’t get this place.”

Advocates of increased military spending fumed after House GOP leaders abandoned a plan to attach a defense bill directing more than $600 billion to warfighters through September. Instead, the stopgap spending plan is offering only temporary funding at current levels, save for a $5 billion emergency increase to repair damaged warships and beef up ballistic missile defense systems.

Leaving a House Republican conference meeting Wednesday evening, Rep. Bradley Byrne (R-Ala.) said he was “bitterly disappointed” by the move and would not support any stopgap that did not make the Pentagon whole. But on Thursday, he and other defense hawks said they had been persuaded to support the stopgap after receiving assurances from Ryan.

“He’s going to take a strong position for defense” in upcoming spending negotiations with Democrats, said Rep. Michael R. Turner (R-Ohio), a senior member of the House Armed Services Committee.

Another tricky issue for House Republicans involved the extension of a program used by U.S. intelligence agencies to collect electronic communications of foreign spy targets on U.S. soil. National security officials warn that the loss of the program Jan. 1 could harm their ability to protect the country; civil liberties advocates, including members of the hard-right House Freedom Caucus, want the program to be overhauled and resisted a long-term extension.

But the group’s chairman, Rep. Mark Meadows (R-N.C.), said Thursday that its members would stand down after GOP leaders promised a full debate next month on a stand-alone bill to reauthorize the program, known as Section 702.

Trump urged lawmakers to pass the stopgap in a tweet Thursday morning that accused Democrats of forcing a showdown to distract from the tax bill.

“Pass the C.R. TODAY and keep our Government OPEN!” he wrote, referring to a “continuing resolution,” the technical term for the stopgap.

Senate Democrats, who have the ability to block any spending bill if they stick together, waited Thursday to see whether House Republicans could manage to send a bill to the other chamber. Aides of both parties had warned that if the House did not act, the Senate could send the chamber a spending bill of its own that could include measures that House conservatives would find distasteful.

Senate Minority Leader Charles E. Schumer (D-N.Y.) said Thursday that Democrats would agree only to a short-term measure as long as broader disputes about spending, immigration and more remain unresolved.

"We're not going to allow things like disaster relief to go forward without discussing some of these other issues we care about," he said. "We have to solve these issues together."

But Democrats have split over how far to push for legislation that includes their key priorities — most of all, legislation granting legal status and a path to citizenship for immigrants brought illegally to the United States as children, known as “dreamers.” Activists and many lawmakers have said they are willing to force a shutdown unless the issue is addressed.

In a stark display of the divide among Democrats about how to proceed, more than a dozen members of the Congressional Hispanic Caucus marched from the House floor to Schumer's office across the U.S. Capitol on Thursday afternoon, demanding to see the Democratic leader.

Members of the caucus said they wanted to pressure Schumer and Democratic senators to withhold support for the spending bill unless Republicans commit to holding votes on legislation providing permanent legal protections to dreamers.

Emerging from the meeting, caucus members said Schumer assured them that more Democratic senators would vote against the spending bill than the 14 who did so two weeks ago, the last time Congress temporarily extended government funding.

Several people who attended the meeting, granted anonymity to describe what was expected to be a private exchange, said Rep. Luis Gutiérrez (D-Ill.) — arguably the most outspoken Democrat on immigration matters — unloaded on Schumer, accusing him and Democratic senators of not caring about the fate of dreamers and “throwing them under the bus” in the ongoing spending debate with Republicans, participants said.

In response, Schumer raised his voice, telling Gutiérrez not to insult fellow Democrats.

Gutiérrez shot back, telling Schumer: “Don’t raise your voice.”

In a signal of growing frustrations, 29 Senate Democrats voted to oppose the stopgap. Only seven opposed the previous stopgap passed Dec. 7.

House Minority Leader Nancy Pelosi (D-Calif.) and Minority Whip Steny H. Hoyer (D-Md.) testified at a House Rules Committee hearing Thursday morning, advocating for the inclusion of language that would grant legal status to dreamers, as well as a comprehensive spending agreement that would raise spending on both defense and nondefense programs.

Without those, they said, Democrats would not be able to support the stopgap.

“Unless we see a respect for our values and priorities, we continue to urge a strong NO on the Continuing Resolution,” Pelosi said in a letter to House Democrats on Wednesday.

As a result, House Republican leaders were under major pressure to assemble enough GOP votes to pass the measure.

The disaster bill, meanwhile, hung by a thread Thursday. Republican leaders sought Democratic votes, inserting provisions late Wednesday directing additional funding to Puerto Rico and the U.S. Virgin Islands in response to Democratic leaders’ demands.

Democrats indicated that it would not be enough, pointing to various tax and spending provisions.

Disaster funding “may have to slip to next year,” Schumer said. “I think we can work it out in a bipartisan way, I certainly do, but just jamming it through without consulting us and not being fair to so many other parts of the country doesn’t make sense.”

Another controversial provision was also added to the House stopgap Wednesday: a measure waiving mandatory cuts to entitlement programs forced by the passage of the tax bill.

The tax bill slashed revenue by nearly $1.5 trillion, according to the nonpartisan Joint Committee on Taxation, adding to the federal deficit. That impact triggers a 2010 law that makes automatic spending cuts to Medicare and other programs if lawmakers increase the deficit.

Democrats opposed the GOP tax bill in part because they said it was fiscally irresponsible, and some said they would not help Republicans by passing the waiver — particularly as many Republicans have vowed to target deep spending cuts to social welfare programs next year. But Democrats — who are typically fiercely opposed to any reductions in Medicare, which would see roughly $25 billion in cuts per year — did not object Thursday.

In the Senate, Sen. Rand Paul (R-Ky.), a fierce advocate for lower federal spending, accused his fellow Republicans of reneging on calls to cut spending and forced a separate vote on the waiver.

“We have a spending problem,” Paul said on the Senate floor, urging colleagues to vote it down. “We have rules to keep spending in check, and we disobey our own rules.”

The waiver passed 91 to 8, averting the mandatory cuts.

Ed O’Keefe and Damian Paletta contributed to this report.