A key measure of U.S. producer prices unexpectedly fell in July for the first time in more than two years, largely reflecting a drop in energy costs and representing a welcome moderation in inflationary pressures.

The producer price index for final demand decreased 0.5% from a month earlier and rose 9.8% from a year ago, Labor Department data showed Thursday. The pullback was due to a decline in the costs of goods, though services prices only edged up.

Excluding the volatile food and energy components, the so-called core PPI rose 0.2% from June and 7.6% from a year earlier. Both the overall and core figures were softer than forecast.

The figures suggest some pipeline inflationary pressures are beginning to ease, which could ultimately temper the pace of consumer price growth in coming months. Commodity prices, including oil, have dropped sharply in recent months, and there are indications that supply-chain conditions are improving.

Treasury yields remained lower while the S&P 500 opened higher and the dollar weakened.

Consumer-price data out Wednesday also showed a welcome moderation in inflation in July, largely reflecting a pullback in prices at the pump. Even so, inflation remains stubbornly high and will likely keep the Federal Reserve on an aggressive path to curb it.

Some 80% of the decline in goods prices was due to a 16.7% plunge in gasoline prices, the report showed. Diesel, iron and steel scrap and grains also decreased.

Services prices rose just 0.1% in July, led by an increase in fuel margins and transportation and warehousing. Still it was the smallest advance in three months as prices for portfolio management, food and alcohol retailing and long-distance trucking declined.

Thursday's report adds to separate data from S&P Global and regional Fed banks that showed a pullback in prices paid for inputs like materials in July.

Risks remain, however. While supply chains have started normalizing, the war in Ukraine, labor negotiations at West Coast ports and China's zero-COVID policy represent potential logistics speed bumps for U.S. producers.

Producer prices excluding food, energy, and trade services, which strips out the most volatile components of the index, increased 0.2% from June and 5.8% from a year earlier.

Costs of processed goods for intermediate demand, which reflect prices earlier in the production pipeline, slumped 2.3%, the most since April 2020. More than half of the drop was attributable to a plunge in diesel costs. Excluding foods and energy, these costs dropped 0.2%.

Reade Pickert reports for Bloomberg News.

Copyright 2022 Bloomberg. All rights reserved. This material may not be published, broadcast, rewritten, or redistributed.