Congress is poised this week to dive into an epic fight over spending, as the Senate for the first time in years puts appropriations bills on the floor for debate and Speaker Kevin McCarthy tries to find his way out of a complex funding tangle that could ultimately threaten his leadership post.

With less than three weeks remaining before government funding runs out on Sept. 30, Congress has not cleared any of its 12 annual appropriations bills, though there has been more progress than in the recent past. Given the rapidly approaching deadline, leaders of both the House and the Senate agree that a temporary stopgap funding measure will be needed to avert a government shutdown beginning Oct. 1. But that usually routine legislation is facing major obstacles in the Republican-led House, making its path to President Biden’s desk unusually fraught.

Members of the House’s far-right Freedom Caucus are pledging to oppose even a temporary measure if it does not cut funding substantially or include new border controls and restrictions on prosecuting former President Donald J. Trump. At the same time, senators of both parties want the stopgap bill to include billions of dollars in new assistance to Ukraine, a demand that House Republicans are resisting. House Democrats want nothing to do with any of the Republican bills, which have also been loaded with conservative social policy riders that have little chance of enactment.

“Honestly, it’s a pretty big mess,” Senator Mitch McConnell, Republican of Kentucky and the minority leader, recently told an audience in his home state.

The major obstacle for Mr. McCarthy is that a significant segment of the hard-right members in his ranks are insisting on conditions on the temporary funding measure that could never clear the Democratic-led Senate even as they call for deeper spending cuts in the full-year spending measures that many of their fellow House Republicans will not support. That internal divide and differences over abortion policy and other issues forced Mr. McCarthy to pull funding measures from the floor just before the August recess.

With only four G.O.P. votes to spare, Mr. McCarthy can afford few defections if he hopes to pass spending bills with only Republican support, and the archconservatives are digging in while dismissing the political and economic repercussions of a government shutdown. They have also rejected Mr. McCarthy’s argument that a shutdown would stall Republican investigations and a potential impeachment of Mr. Biden.

Representative Chip Roy, an ultraconservative Republican from Texas, warned last week on X, formerly Twitter, that “hiding behind impeachment to screw America with status quo massive funding” would “not end well.” He also ridiculed “hand-wringing” over the potential consequences of a shutdown and urged Republicans to prepare for a showdown when they returned to Capitol Hill.

“Saddle up,” Mr. Roy wrote.

An added complication for Mr. McCarthy is that a stopgap measure would keep the government funded at a level set in December 2022, when Democrats still controlled both the House and the Senate. Only a handful of House Republicans voted for the money in that huge catchall spending measure, and most of them have since left Congress.

“We are talking about continuing-resolution levels that almost all of us just voted against,” said Representative Ken Buck, Republican of Colorado, predicting that many Republicans would balk at backing a stopgap measure if the funding remained steady. “I honestly think McCarthy will need to get it done with Democratic votes, and there will be other consequences for that.”

Should Mr. McCarthy be compelled to turn to Democrats to pass the stopgap measure or other funding bills, as he did in May to avert a federal default by suspending the debt limit, some Republicans are already threatening to challenge his leadership position by calling on the House to vacate the speaker’s chair.

“I think that everything is on the table to hold the speaker accountable,” Representative Bob Good, Republican of Virginia, said last week in an interview on Fox Business Network. He said Mr. McCarthy would need to chose between cutting a deal with Democrats or returning government spending to prepandemic levels.

One potential advantage for Mr. McCarthy is that the Biden administration has requested $16 billion in emergency disaster funding for recovery from storms, floods and wildfires in Florida, Hawaii, Vermont and elsewhere. A reluctance to oppose disaster aid can sometimes elicit votes from otherwise recalcitrant lawmakers.

The funding dynamic is entirely different in the Senate, where Republicans and Democrats on the Appropriations Committee have been working cooperatively to advance spending bills at a higher level than what is being considered in the House. Leaders of the panel have also kept the bills free of the contentious policy riders that are drawing fire in the House.

The Senate this week is scheduled to consider measures funding veterans, agriculture and housing programs — the first time in years that spending bills have been considered separately on the floor as the chamber strayed far from the traditional appropriations process. Votes on proposals to change the legislation are anticipated, but Senate leaders hope to win quick approval, providing leverage over the House should Mr. McCarthy be unable to push any spending bills over the finish line. The House is planning this week to take up just one spending bill covering the Pentagon.

“We have provided a clear bipartisan road map to fund the government under extremely difficult constraints, proving Congress can work together and through its differences,” said Senator Patty Murray, Democrat of Washington and the chairwoman of the Appropriations Committee.

Yet the differences between the Senate and the House are significant, and House conservatives have made it clear that they regard their push to substantially rein in spending as far more consequential than the repercussions of letting funding for federal agencies run out.

“If a temporary shutdown is more concerning to you than our $2 trillion deficit and $33 trillion national debt, I’d politely suggest you’re part of the problem,” Representative Ralph Norman, Republican of South Carolina, wrote on X last week.

But Democrats stand ready to point the finger at House Republicans if government agencies are shuttered, and Mr. McCarthy is painfully aware that his party would be blamed for a shutdown.

“A shutdown is unnecessary and would harm many American families and businesses — just about everybody,” said Senator Chuck Schumer, Democrat of New York and the majority leader. “We hope the House comes to its senses and follows our example.”