The average price of a gallon of regular unleaded gas in the U.S. hit $5 Friday night, and the rise in fuel costs is expected to persist throughout the busy summer driving season. The record high, according to OPIS, an energy-data and analytics provider, comes as U.S. consumer inflation hit its highest level in 40 years and crude oil prices remain high.

Gas prices skyrocketed after Russia’s invasion of Ukraine earlier this year, with traders, shippers and financiers shunning Russian oil supplies. Oil inventories, which were already tight because of higher demand from economic reopening, have depleted even more, with no sign of relief ahead.

That has translated to pain at the pump, further squeezing Americans’ household budgets already hit by higher prices on everything from items at the grocery store to restaurant meals and air travel. Prices for energy jumped 34.6% from a year earlier, while the cost of groceries rose 11.9% on the year, adding to consumers’ woes.

Shenetha James, a mother of four kids in Jackson, Miss., hasn’t seen her eldest daughter, who lives about 700 miles away in North Carolina, since Christmas, because of high gas prices.

The average cost of a gallon of unleaded gas in Mississippi was still below the national average Friday, at about $4.52, according to OPIS, which is part of Dow Jones & Co., publisher of The Wall Street Journal.

“It’s been kind of hard,” Ms. James said, “not being able to really be there.”

Ms. James, who works for the Mississippi Department of Child Protection Services, drives one kid to basketball practice and another to work at Chick-fil-A a few times a week. After dropping them off, to save money on gas, Ms. James waits in a parking lot instead of driving back home.

“We’ve got to manage this gas to get from one pay period to another,” she said.

Analysts say high gas prices could persist. A report from JPMorgan last month said retail gas prices could jump to $6.20 a gallon by August. The cost of gas on average has already exceeded that price in California, where gas was about $6.43 on average Friday, according to OPIS.

“People are still fueling up, despite these high prices,” said Andrew Gross, a spokesman at AAA. “At some point, drivers may change their daily driving habits or lifestyle due to these high prices, but we are not there yet.”

AAA, an automobile organization, obtains data from OPIS.

Some drivers are purchasing fewer gallons on each visit to gas stations but making more frequent trips to fuel up. Patrick De Haan, head of petroleum analysis at price tracker GasBuddy, said consumer resilience has remained relatively strong, even as demand has started to waver. He projects people will more significantly adjust their driving habits when gas hits between $5.40 and $5.50.

That is around the price that, adjusted for inflation, would surpass the 2008 peak for gas prices, Mr. De Haan said.

“We’re getting to the point where there’s probably a lot more demand destruction ahead as consumers come to grips with the higher fuel prices—something we’ve never seen to this magnitude,” Mr. De Haan said.

Chris Stevenson, a 24-year-old from New Jersey, said he’s just going to ignore the prices for as long as possible.

“I don’t care about the gas. I’m doing a lot of trips,” he said while filling up at a Manhattan gas station Friday afternoon. The average price of gas in New York City was $5.18 a gallon according to OPIS. “It’s summertime, so you know, we have to be outside,” he added.

SHARE YOUR THOUGHTS

How have surging gas prices affected your lifestyle? Join the conversation below.

Pandemic-related strains have added pressure on prices. Refineries around the world closed some plants after Covid-19-related lockdowns and travel restrictions dragged down fuel demand. Now, as demand hovers closer to prepandemic levels, the shortage of online refineries is exasperating the market and contributing to high gas prices.

President Biden has been under pressure to address rising gasoline prices. He might meet with leaders in the Middle East later this month. The potential trip comes as the Organization of the Petroleum Exporting Countries and 10 non-OPEC producers agreed last week to a larger-than-expected oil-production increase.

Under the agreement, the oil-producing nations will raise output by 648,000 barrels a day in July and in August.

The Biden administration has also tapped oil supplies from the U.S. Strategic Petroleum Reserve, releasing one million barrels of oil a day. The U.S. Environmental Protection Agency issued an emergency waiver in April allowing gas stations to sell high-ethanol-content gasoline this summer, despite environmental concerns.

Scott Solis, a 51-year-old resident of Goodyear, Ariz., who lives on a fixed income, said he has limited his trips to grocery and retail stores because of high gas prices.

He added that he used to go on sightseeing driving trips to Sedona and Flagstaff with his wife and friends. The average cost of a gallon of gas in Arizona was $5.31 Friday.

“There’s no way in heck we can do that now,” Mr. Solis said.