WASHINGTON — Congress narrowly avoided a government shutdown Thursday with a short-term spending bill that punted thorny debates over immigration and health care to next month.

Still basking in the passage of their sweeping tax overhaul — and eager not to distract from it by shuttering federal agencies — Republican leaders settled on a stripped-down bill that disappointed members of both parties but will keep the government running through Jan. 19.

While lawmakers dodged a shutdown that would have taken place tonight at midnight, the duct-tape approach to government funding underscored how difficult it will be for Congress to negotiate a longer-term bill in the new year.

The outcome of those talks will have implications for Maryland, a state that is home to roughly 300,000 federal employees.

“This is ridiculous,” said Maryland Sen. Ben Cardin, a Democrat. “They control both the House and the Senate and the White House and they can’t pass a budget?”

The House approved the spending measure, 231-188. Hours later, the Senate passed it, 66-32.

House Speaker Paul Ryan said he was disappointed that most Democrats opposed the legislation.

“I hope that they will return in the new year willing to work with us to complete our work, most importantly to adequately provide for our men and women in uniform,” Ryan said in a statement.

A final agreement on funding the government through the rest of the fiscal year — assuming lawmakers can reach one next month — would answer a number of outstanding questions for Maryland, such as whether Congress wants to continue to help pay for Chesapeake Bay cleanup and whether the Bethesda-based National Institutes of Health would face a cut.

The latest stopgap measure answers none of those questions, though it did include funding for states expected to run out of money for a children’s health program. That popular program, which expired in October, covers 9 million children nationally and about 146,000 in Maryland. The state has enough money to keep it running through March.

The House also approved the largest disaster aid bill in U.S. history, $81 billion, in response to the California wildfires and the hurricanes that hit the Gulf region this year. The Senate was not expected to vote on that legislation until after the start of the new year.

Rep. Andy Harris, a Baltimore County Republican, voted against a stopgap spending bill earlier this month but voted for the legislation Thursday. Harris said he voted for the more recent bill because it included additional money for defense and also because it contained a provision that will allow President Donald J. Trump to sign the tax bill without affecting Medicare.

The GOP tax law approved this week would have triggered automatic spending cuts to Medicare without the fix.

Harris said he feels more confident that Republicans will achieve a central goal in the budget negotiations next month — increasing defense spending — but said the debate may hinge on Democratic demands to increase funding for other programs as well.

“There’s an increasing realization on both sides of the aisle that we need to increase defense spending,” Harris said. “The big discussion is going to be how much do we increase non-defense spending in order to get there. That’s going to be the stumbling block.”

Rep. John Delaney of Montgomery County was one of only 14 House Democrats — and the only Democratic member of Maryland’s congressional delegation — to support the bill. Delaney is running for the Democratic presidential nomination in 2020.

Talks over the short-term measure eased this week when Republican Sens. Susan Collins of Maine and Lamar Alexander of Tennessee backed off demands to include payments to stabilize the Affordable Care Act’s marketplaces as part of the spending bill. Insurers have said the payments, which Trump ended in October, reduce premiums. Opponents describe them as a “bailout” for the insurance industry.

Many Democrats, meanwhile, appeared to back off a demand that the spending measure deal with the “dreamers,” or immigrants brought to the country illegally as children. Negotiations on that issue are underway and Senate Majority Leader Mitch McConnell pledged this week that he would bring a bill to the floor next month if Republicans and Democrats worked out an agreement.

There are roughly 8,000 people protected from deportation and allowed to work in Maryland under the Deferred Action for Childhood Arrivals program, according to a Department of Homeland Security estimate in September. Honoring a campaign pledge, Trump ended the program in September.

Neither of those issues are disappearing. Lawmakers will have to confront them — as well as another knotty debate over whether to raise defense and domestic spending — in order to reach a final agreement on spending. Lawmakers want to ultimately approve legislation that would fund the government through the end of the current fiscal year — next Sept. 30.

Trump, who is expected to sign the short-term agreement, tried to cast blame for the brinkmanship Thursday onto Democrats. Democrats control neither the House nor the Senate, though they have leverage in the Senate, since the Republicans’ majority there is so thin. Because of internal divisions, House Republicans have historically needed some Democratic votes to approve spending measures.

“House Democrats want a SHUTDOWN for the holidays in order to distract from the very popular, just passed, Tax Cuts,” the president wrote on Twitter. “House Republicans, don't let this happen. Pass the C.R. TODAY and keep our Government OPEN!”

“CR” is a reference to the continuing resolution, the technical term for legislation that keeps the government running at current spending levels for a short period.

The spending measure will keep most government operations running at current levels, but includes some increases for the military. Among those is about $5 billion to shore up missile defense systems — a response to the threat from North Korea.

john.fritze@baltsun.com

twitter.com/jfritze