Orange County, Calif., symbolized Republican struggles in America’s diverse and highly educated suburbs during Donald J. Trump’s presidency, as a backlash to Mr. Trump transformed center-right strongholds into increasingly Democratic territory.

But at a Chevron station in Santa Ana near John Wayne Airport on Friday afternoon, the anger was aimed at President Biden and his party, as Californians grappled with gas prices registering that day at $6.59 a gallon.

“I’m really unhappy,” Carmen Vega, 47, of Anaheim, said, adding that she voted for Mr. Biden but was now considering backing Republicans in the midterm elections. “The economy sucks right now, everything’s too expensive.”

And as Simona Sabo, 38, of Irvine, waxed nostalgic for Mr. Trump while filling up her S.U.V. — “What I liked was that gas prices weren’t this high” — another woman poked her head around the pump and offered a silent thumbs up before driving away.

Five months before the midterm elections, Democrats are straining to defend their narrow House majority in a brutal political environment shaped by high inflation, Mr. Biden’s low approval ratings and a strong sense among many Americans that the country is on the wrong track. But they have held out hope that a handful of California congressional contests will emerge as bright spots, thanks to the redistricting process that made some seats more hospitable to Democrats, and the importance of issues including abortion rights and gun control to many coastal voters.

Yet in California, home to the highest average price for regular gasoline in the nation — $6.326 on Sunday, according to the motor club AAA, compared with the nation’s average of $4.848 — anger over the cost of living is threatening Democrats’ ambitions. (California gas prices are typically the highest in the nation, owing in part to state taxes and regulations on emissions that require a more expensive blend of gasoline, but recent numbers have been eye-popping.)

On the cusp of Tuesday’s primary elections that will determine California’s general election matchups, there are signs that the cost of living is overshadowing virtually every other issue in some of the state’s battleground areas, according to elected officials, party strategists and polling.

“They’re beyond furious — it’s called desperation,” said Representative Lou Correa, a Democrat from Santa Ana, whose district is considered safely Democratic but neighbors more competitive Orange County seats. “I don’t hear anything about the other national issues we’re focusing on in Washington. The thing I hear about is gasoline. What are you going to do to bring down the gas prices?”

An ABC News/Ipsos poll released Sunday found that most Americans called the economy, inflation and rising gas prices the most important issues in determining their midterm votes. Just 28 percent of those surveyed approved of Mr. Biden’s handling of inflation, and 27 percent approved of his handling of gas prices.

“The problem for the Democrats here will be that all of the contributing economic factors, particularly inflation, that’s hurting them nationally is on steroids in California,” said Rob Stutzman, a veteran California Republican strategist who is assisting some independent statewide candidates this year. “Seats that, when the maps got drawn, that they didn’t think would be competitive very well could be,” he added.

The contours of those House races will come into clearer focus after Tuesday’s primaries, which have so far appeared to be low-turnout affairs. In California primaries, the top two vote-getters, regardless of party, then move on to the general election.

The races against Representatives David Valadao and Mike Garcia, two Republicans, are expected to be highly competitive in general elections, given the Democratic tilt of both their new districts.

Mr. Valadao, of the Central Valley, is one of 10 Republicans who voted to impeach Mr. Trump after the Jan. 6 Capitol riot, and he also faces primary challenges.

Mr. Garcia, of Santa Clarita, who won his last election by just 333 votesvoted against certifying the results of the 2020 election. Democrats are locked in a primary to challenge him.

There are also primary contests for a newly redrawn open seat in California’s 13th Congressional District near Fresno, which leans Democratic, according to the Cook Political Report, though the race may well be highly competitive.

Several Republican primary contests may determine how close a number of Southern California seats become. National Republicans see a chance to defeat Representative Mike Levin, a Democrat, but there is also a competitive primary to challenge him.

There has also been something of a Republican rescue mission for Representative Young Kim. Her primary contest this year grew unexpectedly competitive, and her newly redrawn district would become far more tightly contested in November should she lose.

Two other high-profile House races are unfolding in Orange County, a place once strongly associated with Ronald Reagan and Richard Nixon, staunchly conservative former presidents, but now a prominent political battleground.

Representative Michelle Steel, who like Ms. Kim is a Korean American Republican who flipped a seat in 2020, is running in a new, heavily Asian American district in what is expected to be a close race against Jay Chen, a small-business owner and lieutenant commander in the U.S. Navy Reserve. The newly drawn district somewhat favors Democrats.

And Representative Katie Porter, a Democrat with a national platform and a huge war chest, is running in a redrawn seat that is roughly evenly politically divided.

She and many other Democrats argue that their party is trying to bring down gas prices — which have spiked for reasons including Russia’s invasion of Ukraine — while charging that Republicans embrace the issue as a political cudgel. And certainly, there is still time for gas prices and other costs to come down before the midterms, amid other positive economic indicators, and for the political environment to improve for Democrats in competitive races.