TOKYO — Japan’s exports grew 14 percent over a year earlier in October on strong demand for vehicles, electronics and machinery. However, customs data released Monday showed even faster growth in imports of oil, gas and coal that caused the trade surplus to fall more than 40 percent from the year before.

As China recovers momentum following a slowdown, demand from the region’s biggest economy is helping to breathe fresh life into its neighbors’ economies.

Exports are helping to drive a moderate recovery in Japan, the world’s third-largest economy, as its factories struggle to keep up with demand for cars, electronic components and manufacturing equipment.

At the same time, Japan’s imports have risen thanks to higher costs for crude oil and other commodities: surging 19 percent from the same month a year earlier in October to 6.41 trillion yen ($57 billion) versus exports of 6.7 trillion yen ($59 billion). The resulting surplus of 285.4 billion yen ($2.54 billion) compared with a 481.2 billion yen surplus a year earlier and 667.7 billion yen in September.

China displaced the U.S. as Japan’s biggest export market in October, as shipments to Asia’s biggest economy jumped 26 percent to 1.35 trillion yen ($12 billion). Its imports from China rose 14 percent to 1.62 trillion yen ($14 billion).

Japan’s surplus with the U.S. jumped 11 percent to 644.7 billion yen ($5.75 billion) on exports of 1.28 trillion yen ($11 billion), led by chemicals and machinery. Imports from the U.S. climbed 3.1 percent to 637 billion yen ($5.7 billion), with the biggest growth in imports of fish, soybeans, coal, liquid petroleum gas and iron ore.

Imports of crude oil, gas, coal and other fuels surged 37.5 percent from a year earlier to 1.24 trillion yen ($11 billion). Rising prices and the weakening of the Japanese yen over the past year contributed to that increase.

“Looking ahead, the export climate index remains elevated and suggests that export growth will continue at a similar pace as the 6.4 percent year-on-year increase recorded last quarter,” Marcel Thieliant of Capital Economics said in a commentary.

But the economies of Japan’s major trading partners are likely to slow in the next year, he said. “We therefore we expect real export growth to slow from 6 percent year-on-year this year to 3 percent in 2018.”