HONG KONG—Higher commodity costs drove China’s factory-gate prices to rise in August by their fastest pace in 13 years, defying aggressive moves by Beijing to tame a rally in metals prices.

Robust demand for coal, steel and other raw materials pushed China’s producer-price index 9.5% higher in August from a year earlier, the fastest increase since August 2008, when it rose 10.1%, according to China’s National Bureau of Statistics. The result beat the 9% forecast by economists polled by The Wall Street Journal.

While prices for some global commodities, such as oil, were relatively stable last month, sharp rallies in coal and gas markets put upward pressure on China’s economy, where roughly 60% of energy consumption is derived from coal, according to economists from HSBC.

To curb the rally in commodity prices, Chinese authorities have been selling from state stockpiles while clamping down on hoarding and speculation among producers—all with limited effect on producer prices, which have climbed steadily since the spring.

China’s food prices dropped 4.1% in August from a year earlier.

Photo: alex plavevski/Shutterstock

At the same time, China’s efforts to rein in steelmaking—part of broader carbon emissions reduction measures—have pushed up the price of steel, a key input for the real-estate sector.

A sustained stretch of elevated input costs will add to profit-margin pressures for manufacturers and factory owners in the world’s second-largest economy. Many have already been wrestling with surging shipping costs and supply-chain bottlenecks since the pandemic began last year.

The uptick in factory inflation last month suggests that China’s inflation pressure isn’t likely to disappear soon, though the spillover into consumer prices will stay limited.

China’s consumer-price index stayed muted in August. Authorities in many provinces placed stringent social-distancing restrictions to contain the spread of the Delta variant of the coronavirus, which dented demand for services and tamped down prices of things like airplane tickets and hotel rooms.

The country’s consumer-price index rose 0.8% from a year earlier, down from July’s 1% year-over-year growth, the statistics bureau said. The price of pork, a staple meat in China and a major item in the country’s CPI basket, continued to fall in August. Overall, food prices dropped 4.1% in August from a year earlier, while nonfood prices increased 1.9%.

Economists warn that a widening gap between producer and consumer inflation could further squeeze profit margins for manufacturers and service providers, potentially adding stress to China’s labor market as well as downward pressure on overall economic growth.

To stave off a sharp slowdown, China’s central bank could cut the amount of cash that banks must hold as reserves again later this year, effectively freeing up liquidity for lending, analysts say. The central bank made such a move in July as inflation worries showed signs of easing.

With global demand still robust for Chinese-made goods such as household electronics, clothing and furniture, China’s exports have consistently beaten expectations all year. In August, exports jumped 25.6% from a year earlier.

Still, much of the rising input costs have so far been absorbed by Chinese manufacturers, who in some cases have stopped accepting new orders as they struggled to pass on costs.

‘It has been quite difficult for a lot of manufacturers to pass on the increase of costs to importers and their customers within China.’

— Louis Kuijs, Oxford Economics

Calculations by Oxford Economics show that factory-gate prices for goods in heavy industries such as the chemicals, iron and steel sectors jumped by 18.7% in July from a year ago. Meanwhile, prices for light industrial products such as textiles saw a more modest 2.3% increase.

“It’s striking how contained the PPI inflation remains in China,” said Louis Kuijs, the economic research firm’s Asia head. “It has been quite difficult for a lot of manufacturers to pass on the increase of costs to importers and their customers within China.”

The surge in producer prices also reflects a pickup in domestic demand for steel and other materials this summer as property developers—facing the prospect of more government regulation—race to finish up projects, according to Zhaopeng Xing, an economist in Shanghai for Australian bank ANZ.

Looking ahead, economists predict that the increase in China’s factory-gate prices is likely to ease in the final months of this year, in part due to last year’s higher base of comparison—when the country’s economy had mostly bounced back from the effects of the pandemic—and softening demand that could pull back metal prices.

Unlike central banks in other Asian economies such as the Philippines and Taiwan, where consumer prices have been rising or have rebounded unexpectedly, Chinese policy makers face few constraints if they choose to ease monetary policy. In China, consumer inflation is expected to remain muted far below policy makers’ target of around 3% through the end of the year.

Write to Stella Yifan Xie at stella.xie@wsj.com