Inflation in the U.S. slowed in July and a measure of underlying price pressures also cooled, according to official data Wednesday that suggested higher oil and gas prices from the Iran war were only having a limited impact on broader costs in the economy.

Consumer prices rose 3.4% last month from a year ago, down slightly from 3.5% in June, the Labor Department said Wednesday. But inflation is still higher than before the Iran war began in February, when it was 2.4%. On a monthly basis, prices rose just 0.1% from June to July.

The modest decline could ease pressure on the inflation-fighters at the Federal Reserve (Fed) and may give them some room to maneuver ahead of potential rate hikes.

Yet prices are still rising more quickly than average wages, underscoring the struggle many Americans have had with more expensive groceries, gas, and health care, trends that have taken on a high profile in the fast-approaching midterm elections.

U.S. households have been battered by more than five years of elevated prices since the pandemic hit, and the July data is still well above the Fed's long-term 2% target.