Japan ran a current account deficit for the first time in five months in June as surging imports eclipsed exports, data showed on Monday, highlighting the pressure that higher energy and raw material prices are putting on the economy.

The world's third-largest economy ran a current account deficit of ¥132.4 billion ($980 million) in June, government data showed, reversing ¥872 billion from the same month a year earlier.

The data, which marked the first monthly deficit since January, was smaller than economists' median forecast for a ¥703.8 billion shortfall in a Reuters poll.

High prices for energy sources like oil and coal drove the value of imports to a record, surging 49% year-on-year and outpacing a 20% rise in the value of exports led by "mineral fuels" and steel.

The current account data underscored the change in Japan's economic structure as the country earns hefty returns from its portfolio investments and direct investment overseas, which are offsetting deficits in its trade balance.

The current account surplus has declined for four fiscal years in a row through March 2022.

While yen weakness has inflated the cost of imports, its boost to the value of exports has not been as great as it once was due to an ongoing shift of exporters' production abroad.