By Richard Cowan and Moira Warburton

WASHINGTON (Reuters) -The U.S. House of Representatives on Wednesday passed a stopgap bill to avert a partial government shutdown beginning next week, even as a large number of Republicans revolted against their leadership for failing to achieve new federal spending cuts.

The stopgap funding bill, which passed in the House by a margin of 341-82, will maintain the government’s current level of roughly $1.2 trillion in annual discretionary funding through Dec. 20, avoiding the furloughing of thousands of federal workers and shutdown of a wide swath of government services just weeks before the Nov. 5 election.

House Speaker Mike Johnson was forced to use a parliamentary maneuver to bypass the House Rules Committee to overcome opposition within his own Republican Party, which holds a 220-212 majority in the chamber. All 82 “no” votes were cast by Republicans.

The bill will now be sent to the Democratic-majority Senate is also set to vote on the bill on Wednesday and send it on to be signed into law by President Joe Biden before current funding expires at midnight Monday.

The timeline is unusually truncated for Congress, as members moved quickly in order to get back to campaigning in their districts ahead of the election.

A significant number of House Republicans defied their leader and voted against the measure, after Republican presidential candidate Donald Trump earlier spoke in favor of a shutdown unless controversial legislation was attached to the spending bill that outlawed non-citizens voting in federal elections, something that already is illegal.

Hard-right House Republicans had been pushing for a six-month stopgap measure with the election piece attached, but last week failed to pass that bill, which would have been lost in the Senate anyway.

Nonetheless, some of the most conservative Republicans thought Johnson and all rank-and-file Republicans should have fought harder against a Democratic victory, even if it meant a shutdown.

The Moody’s credit ratings agency warned this week that it expects the polarized U.S. political environment to cause the federal government’s fiscal health to deteriorate. The last of the three major rating agencies to maintain a top rating for the U.S. government in November 2024 lowered its credit outlook on the U.S. to “negative.”

Johnson has repeatedly had to bypass his own restive caucus to pass critical legislation. In March, the House passed the current funding bill despite 112 Republican “no” votes.

April brought the passage of nearly $61 billion in new aid for Ukraine, which has battled a Russian invasion since 2022. Again, 112 Republicans voted against Johnson’s effort.

Johnson’s predecessor, then-Speaker Kevin McCarthy, was ousted by right-wing Republicans in an historic vote, as they punished him for reaching a bipartisan spending and debt limit deal with Biden.

That latter fight will recur late this year. Democrats and Republicans will have to negotiate over full-year government funding. And it faces an even more critical self-imposed Jan. 1 deadline to either to raise the nation’s debt ceiling or risk defaulting on more than $35 trillion in federal government debt.

(Reporting by Richard Cowan, Moira Warburton and Bo Erickson; Editing by Scott Malone, Lincoln Feast and Alistair Bell)