Speaker of the House of Representatives Kevin McCarthy walks to a meeting at the Capitol in Washington, Sept. 29, 2023. [AP Photo]

The U.S. House of Representatives voted Saturday to fund the federal government for 45 days, potentially averting a shutdown of the federal government hours before the deadline.

The vote, 335-91, came after Speaker of the House Kevin McCarthy changed tactics Saturday and offered the bill, which hard-line members of his Republican caucus oppose.

More Democrats supported the measure than Republicans, even though it does not contain aid for Ukraine, which is a priority for President Joe Biden, Democrats and many Senate Republicans.

The Senate will consider the House measure Saturday. If it approves the measure and Biden signs it before midnight Saturday, local time, a shutdown will be avoided.

McCarthy's maneuver came after Republicans in the House failed to pass a short-term spending measure Friday, increasing the chances of a government shutdown when funding runs out at 12:01 a.m. Sunday.

"We're going to do our job," McCarthy said after the morning meeting. "We're going to be adults in the room. And we're going to keep [the] government open."

McCarthy said Friday that passing a short-term funding deal was critical to maintaining security at the U.S.- Mexico border and would buy lawmakers crucial time to negotiate spending priorities, but the measure was defeated by the most conservative members of his Republican Party.

Writing on X, formerly known as Twitter, McCarthy later said another spending bill that originated in the Senate has no chance of winning House approval.

A U.S. government shutdown looked more and more inevitable for Sunday as lawmakers remain at odds over the size of the U.S. budget for the next 12 months, continued aid for Ukraine to fight Russia, immigration controls at the U.S.-Mexican border, and social welfare programs to help impoverished Americans.

Asked about the looming shutdown in an interview Friday with the nonprofit news outlet ProPublica, Biden cast blame on hard-line Republicans.

"There is a group of MAGA Republicans who genuinely want to have a fundamental change to the way the system works and that's what worries me the most," Biden said in the excerpt released by ProPublica. The full interview is to be released Sunday.

Earlier Friday, McCarthy put a short-term continuing resolution, known as a CR, up for a House vote, calling it "a stopgap measure that will fund the government and secure the border."

But the resolution was defeated by a vote of 232-198, with 21 Republicans joining a united Democratic opposition. Even if the measure were to pass the Republican-majority House, it would face little chance of passage in the Democratic-majority Senate.

House Democratic Leader Hakeem Jeffries said after Friday's vote that the Republicans "tried a partisan continuing resolution and they failed."

"And," Jeffries said, "there was no way out of their Republican civil war. The only path forward is to partner with House Democrats in a bipartisan way. And we're prepared to do just that."

The Senate has been working on its own seven-week funding plan that would keep the government fully open through mid-November to give lawmakers more time to set spending levels through next September. The bipartisan legislation allocates $6 billion in supplemental aid for the war in Ukraine and for disaster relief in the United States, two sticking points for conservatives in the House. The Senate may accept the House bill, or it could try to negotiate with the House for changes to the bill, but that is unlikely.

Senate Republican leader Mitch McConnell warned lawmakers earlier this week about the dire effects of shutting down part of the government, especially difficulties in controlling the influx of migrants at the country's southern border with Mexico.

"Shutting down the government is not like pressing pause," McConnell said on the Senate floor Thursday. "It's not an interlude that lets us pick up where we left off. It's an actively harmful proposition. And instead of producing any meaningful policy outcomes, it would actually take the important progress being made on a number of key issues and drag it backward."

If a short-term funding deal cannot be reached, more than 4 million U.S. military service personnel and government workers would not be paid, although essential services, such as air traffic control and official border entry points would still be staffed. Pensioners might not get their monthly government payments in time to pay bills and buy groceries, and national parks could be closed.

Such shutdowns have occurred four times in the last decade in the U.S., but often have lasted just a day or two until lawmakers reach a compromise to fully restart government operations. However, one shutdown that occurred during the administration of former President Donald Trump lasted 35 days, as he unsuccessfully sought funding to build a wall along the U.S.-Mexican border.

"This does look very chaotic, but this is not the first time it's happened," Todd Belt, director of the school of political management at The George Washington University, told VOA. "There is a price that has to be paid here. But that is the price of democracy. It does seem very messy sometimes. But eventually, usually you get some compromise."

McCarthy reached a deal in May with Biden on spending levels for fiscal 2024, but a small faction of far-right House Republicans rejected the deal and now is demanding further spending cuts.

The McCarthy-Biden deal called for $1.59 trillion in discretionary spending in fiscal 2024, but some of the right-wing members of the House Freedom Caucus are demanding another $120 billion in cuts and further border controls.

The cuts would be a relatively small portion of the overall $6.4 trillion U.S. budget and would not affect pension payments or government-provided health insurance for older Americans.

The Senate's short-term spending plan through mid-November could win passage in the House, but only with a mix of Republican and Democratic votes, jeopardizing McCarthy's speakership.

"Many of these hard-right Republicans who are opposed to any sort of deal or bipartisanship are likely not going to get what they want, because they keep asking for more," Belt told VOA.

"Ultimately, I think that McCarthy is going to have to make a deal with House Democrats in order to pass these deals. And if he does that - and he did that once to get the spending limit set - when he did these initial negotiations, those Republicans were very angry with him. They'd be angry with him again."

Biden told a group of donors at a fundraiser Wednesday in San Francisco, "I think that the speaker is making a choice between [retaining] the speakership and American interests."