SHANGHAI, China - China's overall trade surplus shrank nearly 10 percent in May from a year earlier, though its gaps with the United States and Europe continued to expand - suggesting more trade tensions ahead.

The government also reported yesterday that China's index for producer prices, an indicator of inflation, jumped 8.2 percent in May, the fastest rise in more than three years, thanks to higher costs for crude oil and other raw materials compared with a year ago.

Surging prices for such commodities are complicating Beijing's efforts to rein in inflation, which has been hovering at a 12-year high.

China's $20.2 billion trade surplus for May is still relatively large - up from a $16.7 billion gap in April and $13.4 billion in March.

Imports ballooned 40 percent to $100.3 billion, the General Administration of Customs said, reflecting escalating prices for crude oil and other commodities. Exports rose 28 percent to $120.5 billion - still strong despite speculation that the slowdown in the U.S. economy would significantly erode export demand.

The data for May may have been distorted slightly by two factors, said Sherman Chan, an economist with Moody's Economy.com, of West Chester, Pa. She notes that the reduction of the country's weeklong May Day holiday to one day resulted in increased industrial production and exports.

And the surge in imports could be at least partly attributable to a spike in shipments of fuel and other items after the catastrophic earthquake that struck central China on May 12, killing nearly 70,000 people.

"Demand for foreign resources has surged, leading to a larger import bill," Chan said. "Given that the reconstruction work will take an extended period of time to complete, China's appetite for overseas commodities will remain strong in the near term."

China's overall trade surplus for the first five months of the year was $78 billion, down 8.6 percent from the $85.7 billion surplus in January-to-May 2007.

But the gaps with both the United States and the 27-nation European Union grew in May, a fact likely to rankle both trading partners, who are pushing China to import more and make its currency more flexible. Critics contend Beijing is keeping the yuan artificially weak to give Chinese exporters an advantage, even though the yuan has steadily appreciated since its peg to the dollar was cut nearly three years ago.