Japan posted a goods trade deficit in October as rising energy costs led imports to rise at the fastest pace in nearly five years, according to government data released Monday.

The trade balance in goods with the rest of the world came to a deficit of ¥449.3 billion, the first red ink in two months, a preliminary report by the Finance Ministry said.

Imports rose 19.9 percent from a year earlier to ¥7.69 trillion, the highest rate of increase since January 2014. Unrefined oil was the biggest single contributor, jumping 33.7 percent as global market prices climbed before dropping off in early October.