US consumer prices continued to soar in May, pushed higher by surging energy costs more than three months into a war with Iran, according to government data released Wednesday.

Prices rose 4.2% from May 2025 in the hottest annual reading since April 2023, and 0.5% on a monthly basis, according to the Bureau of Labor Statistics, matching economists' expectations. The index for energy prices alone accounted for more than 60% of the increase from April, with prices rising 3.9%.

"Today's CPI data confirmed our expectation that higher energy costs and their ripple effects on the costs of transportation and food would drive May headline CPI higher," Moody's Ratings chief credit officer Atsi Sheth said in a statement. "We expect energy prices to remain a driver of headline inflation until there is greater geopolitical certainty in the Middle East."

Food prices rose 0.2% in May from the previous month as cheese prices fell and coffee continued its march higher. Auto insurance prices declined 1.7% from April's levels, while the cost of hospital services rose 0.7%.

Read more: What is inflation, and how does it affect you?

Across the board, rising prices helped push workers' real average hourly earnings down 0.1%, meaning wages failed to keep pace with inflation.

"Americans are getting squeezed financially," Heather Long, chief economist at the Navy Federal Credit Union, posted on X. "This isn't just 'bad vibes' about the economy. There is real pain, especially for middle-class and lower-income households. It's tough because so many basic items are seeing sizable price increases: gas, electricity, food, medical care."

On a "core" basis, which strips out volatile energy and food costs, prices rose 2.9% from last May and 0.2% from April. Economists had expected a monthly bump of 0.3% and a 2.9% year-over-year rise.

May's CPI report likely reinforces bets that the Federal Reserve will keep interest rates unchanged at its June meeting. Wholesale inflation data out on Thursday will also be important for Federal Reserve policymakers. Last week's jobs data showed the labor market remains broadly in balance, making inflation the larger concern as it remains well above the Federal Reserve's 2% long-term target.

As Yahoo Finance covers the rising cost of living coupled with a challenging job market, we're looking to hear from real workers about what they earn — and whether it's enough. Reach out to emma.ockerman@yahooinc.com to share your story.

Sign up for the Mind Your Money newsletter

Click here for the latest personal finance news to help you with investing, paying off debt, buying a home, retirement, and more

Read the latest financial and business news from Yahoo Finance