Surging food and gasoline prices kept Bay Area inflation at a two-year high in June, an economic after-effect of the ongoing Iran conflict that has rattled crude oil markets worldwide.

The consumer price index in the Bay Area rose 3.8% in June compared to a year ago, the U.S. Bureau of Labor Statistics reported Tuesday.

RELATED: Inflation cools more than expected in June as gas costs fall, underlying prices ease

Worldwide energy costs, including crude oil and gasoline prices, may gyrate while uncertainty remains over the endgame for the Iran conflict, some economists warned.

“Large and volatile changes in energy prices could still stoke downstream inflation pressures if the war in Iran continues,” Scott Anderson, chief economist with BMO Capital Markets, said in a research note regarding the nationwide inflation rate.

Inflation ran hotter during June in the Bay Area than the United States overall. The nationwide annual inflation rate was 3.5% last month, according to the federal labor agency.

The 3.8% June inflation rate in the Bay Area was the same as April. The inflation reports for both months represented the highest levels for the region’s consumer price index in two years.

The last time Bay Area prices rose at an annual pace that was this severe was in April 2024, when yearly costs also rose 3.8%, the federal labor agency reported.

Food prices in the Bay Area soared 5.2% in June compared to the same month the year before, according to the report. The cost of food consumed at home rocketed higher by 6% while the cost of food away from home jumped 4.2%.

The cost of regular unleaded gasoline zoomed 20.8% higher in June in the Bay Area compared with a year ago.

This marked four straight months of annual increases in gasoline prices in this region of at least 15%, with annual costs for gasoline rising at least 20% in April, May and June.

The primary drivers of the higher food costs in the Bay Area were prices for fruits and vegetables, which soared 9.8% higher in June, measured on a yearly basis.

Other regional food categories showed tame changes in costs over the 12 months that ended in June.

Meat, poultry, fish and egg prices were up 3.2%, cereals and bakery prices were up 1.6%, while dairy product prices fell 7.3% in the Bay Area, the federal agency reported.

Other Bay Area consumer categories tracked by the federal agency showed varying paces of change over the year-long period.

Over the one-year period that ended in June, the cost of renting a primary residence rose 2.5%, apparel prices increased 1%, medical costs went up 0.1%, while prices for new and used vehicles fell 0.3%.