Joe Biden signs the stopgap funding bill Saturday night. (Credit: @POTUS/X)

(CNN) -- U.S. President Joe Biden signed the stopgap bill averting a government shutdown approved by Congress just hours before the critical midnight deadline, when funding for federal agencies was about to run out.

The Senate approved the measure Saturday night after the House abruptly reversed course earlier in the day and passed a bipartisan bill to extend government funding after days of uncertainty over whether a shutdown could be avoided.

"Tonight, bipartisan majorities in the House and Senate voted to keep government open, averting an unnecessary crisis that would have inflicted unnecessary pain on millions of hardworking Americans," Biden said in a statement Saturday. He also criticized House Republicans for the last-minute fight, adding, "First of all, we should never have been in this position."

The measure will keep the government open only until Nov. 17 and includes aid for natural disasters, but no additional funding for Ukraine or border security. It also includes a measure to keep the Federal Aviation Administration operational.

  • News Roundup of Possible U.S. Government Shutdown

advertising

House Speaker Kevin McCarthy announced the tentative proposal Saturday morning, a move that came after weeks of infighting among House Republicans and a failed effort to pass a stopgap GOP bill in the chamber. The bill passed the House with an overwhelmingly bipartisan vote.

McCarthy's decision to introduce a bill that would win support from Democrats could put his presidency at risk as hardline conservatives continue to threaten a vote to remove him from the top House leadership post.

McCarthy was defiant after the vote, challenging his detractors to try to oust him while arguing that he did what was necessary to govern effectively.

"If someone wants to file a motion against me, let them file it," McCarthy told CNN's Manu Raju at a news conference. "There has to be an adult in the room. I'm going to govern with what's best for this country."

McCarthy suffered a high-profile defeat Friday when the House failed to advance a last-minute GOP stopgap bill, increasing pressure on him to decide whether he would try to get across the aisle to work with Democrats to keep the government open even if he risked a backlash from conservatives.

Hardliners are expected to force a vote to remove Kevin McCarthy as president, but "not yet," according to a Republican lawmaker.

The House has until this Monday, so it is as soon as possible; Leaders would then have two days to schedule the vote.

  • House Democrats Weigh Risky Strategy: Save Kevin McCarthy or Not

The vote to pass the bill in the House came after a chaotic few hours in which House Republicans met throughout Saturday morning, oscillating between options on how to proceed. Republicans, including veteran appropriators and those in swing districts, pushed to introduce a short-term resolution to keep the government funded in the House of Representatives for a vote Saturday.

The Senate had been working to advance its own bipartisan stopgap bill and was on track to hold a procedural vote Saturday afternoon. But that was put on hold after the House moved quickly to approve the short-term funding extension and senators rallied around the House-passed bill.

House Republicans had poured cold water on the Senate bill, and Republican Senator Rand Paul had vowed all week to delay that process beyond the midnight deadline over objections to aid to Ukraine included in the Senate bill. But Paul told CNN Saturday afternoon that he would not delay Senate consideration of the House-passed spending bill.

A shutdown could have major consequences across the country, from air travel to drinking water, and many government operations would be paralyzed, though services deemed essential to public safety would continue.

-- CNN's Manu Raju and Betsy Klein contributed to this report.

U.S. Government ShutdownUs Congress U.S. Joe BidenKevin McCarthy