Japan fell into red ink in the goods trade for the first time in two months in July as the cost of energy imports surged, government data showed Thursday.

The ¥231.2 billion trade deficit followed the revised ¥720.8 billion surplus logged in June, the preliminary report from the Finance Ministry said.

Exports grew 3.9 percent from a year earlier to ¥6.75 trillion amid an increase in demand for electronic components from the rest of Asia, but were overshadowed by a 14.6 percent rise in imports to ¥6.98 trillion.