Congress on Thursday approved a measure to fund the government into early December, and President Biden signed the bill hours later, staving off a shutdown that was set to occur after midnight.

The votes in the House and Senate followed weeks of hand wringing between the two parties, after Democrats initially sought to move the measure along with another proposal to raise the country’s debt ceiling. Senate Republicans blocked that effort, leaving the country’s ability to borrow unresolved just 18 days before the next major fiscal deadline.

The funding stopgap sustains federal agencies’ existing spending until Dec. 3, at which point Congress must adopt another short-term fix, called a continuing resolution, or pass a dozen appropriations bills that fund federal agencies through the 2022 fiscal year.

The new measure also includes billions of dollars to assist in responding to two recent, deadly hurricanes that battered the Gulf Coast and Eastern Seaboard, as well as other money to aid in resettling refugees arriving from Afghanistan.

Senators adopted the measure Thursday after Senate Majority Leader Charles E. Schumer (D-N.Y.) brokered a deal with Republicans that allowed them to vote on a series of amendments, including one that seeks to block the federal government from spending money to carry out President Biden’s pending vaccine requirements for medium and large-sized businesses. That amendment, and another targeting Afghan aid, require 60 votes to pass and failed in a chamber where Democrats possess a tie-breaking majority.

After raising the debt limit for decades, Republicans in recent years have leveraged it to enact spending cuts while also threatening government default. (JM Rieger/The Washington Post)

House lawmakers followed suit later in the day, sparing what would have been a potentially destabilizing shutdown during the coronavirus pandemic. Federal agencies in recent days had scrambled in preparation for the worst, seeking to safeguard critical public health programs from possible disruption.

“We hope this can be a strongly bipartisan bill because it keeps vital services running,” House Speaker Nancy Pelosi (D-Calif.) said Thursday.

Still unresolved is the fight over the debt ceiling, the statutory limit on U.S. borrowing. The cap allows the government to rack up debt to pay its bills. Treasury Secretary Janet Yellen has told Congress that her agency will run out of flexibility to avoid missing payments after October 18, at which point Washington would face the unprecedented threat of default unless Congress acts.

House Democrats on Wednesday adopted a measure to raise the debt ceiling, but Senate lawmakers have been stymied amid a partisan dispute. Republicans have refused to raise the debt ceiling in the narrowly divided chamber, arguing they should not have to foot the bill for Biden’s broader economic agenda. That has angered Schumer and Democrats, who stress the debt ceiling covers past spending — and point out their party agreed to raise the borrowing limit without issue even under former president Donald Trump.

Republicans led by Senate Minority Leader Mitch McConnell (R-Ky.) have blocked multiple attempts to address the debt ceiling in recent days, arguing that Democrats should use a process known as reconciliation to address the issue. The move allows Democrats to adopt bills with a simple majority. But Schumer has argued it is time consuming and “risky,” creating a stalemate in the chamber with significant economic implications, as the Biden administration warns inaction could plunge the country into a recession.

correction

A previous version of this article misspelled Treasury Secretary Janet L. Yellen’s name. The article has been corrected.