Surging pork prices pushed China’s consumer inflation to a near six-year high in September, complicating Beijing’s effort to stimulate growth but also giving it a strong incentive to buy more agricultural goods from the U.S.

The consumer-price index rose 3% in September from a year earlier, according to data released by the National Bureau of Statistics on Tuesday, bumping up against Beijing’s inflation target of “around 3%” this year. The rise in consumer prices accelerated from August’s 2.8% expansion and topped a median forecast for 2.9% growth from economists polled by The Wall Street Journal.

The main factor was surging pork prices, up 69% from a year earlier--the fastest rise in 12 years--and contributing to more than half of the headline CPI’s September increase, the statistics bureau said. Outbreaks of African swine fever, a highly infectious virus that is fatal to pigs but not contagious to humans, has severely hurt pig output in China, the world’s largest pork producer and consumer.

The quick rise in pork prices and the CPI have already made Beijing more willing to buy pork and related farm goods from overseas markets such as the U.S.

Increasing the purchase of agricultural products from the U.S. could address one of the Trump administration’s major China trade complaints and temper the food-price surge at home.

China’s pork imports in September jumped 72% from a year earlier, following a 76% increase in August, according to calculations by The Wall Street Journal based on data released by China’s customs bureau Monday.

High-level trade talks between China and the U.S. in the past few days yielded a truce, with President Trump saying Beijing would buy American agricultural products worth $40 billion to $50 billion, while he would shelve a planned tariff increase on Chinese imports.

Due to the protracted trade fight, China’s purchases of farm goods from the U.S. plummeted to $8.6 billion in 2018, down from an annualized average of $21 billion recorded between 2012 and 2017, Chinese investment house CICC said in a research report Sunday.

In September, food prices in China rose 11% from a year earlier, the strongest pace in nearly eight years, while nonfood prices moderated to a 1% rise from a 1.1% increase in August.

“The danger of prolonged food inflation is it may drive inflation expectations,” said Ning Zhang, an economist at UBS. Policy makers will have a hard time taming inflation if consumers get used to steadily rising prices, he said.

Meanwhile, China’s producer-price inflation slowed further in September as raw-material prices eased, the statistics bureau said. The producer-price index fell 1.2% year over year in September, compared with a 0.8% decline in August.

“Chinese authorities will need to stand on guard against pork-fueled consumer inflation, though they will probably continue a cautious easing stance to spur economic growth,” Mr. Zhang said.

In a meeting with provincial governors Monday, Chinese Premier Li Keqiang said the Chinese economy is under increased pressure amid sluggish demand, cooling growth momentum in some localities and surging prices of some food items. He urged local officials to withstand the pressure and stabilize prices and employment growth to fulfill China’s economic targets this year.

A poll of economists by The Wall Street Journal expects China’s economic growth to show a further slowdown to 6.1% in the third quarter, which would be the weakest pace in more than 25 years. The National Bureau of Statistics will release the growth and other economic data Friday.