Japan posted its largest goods trade deficit in eight years in January, as imports continued to swell on the back of higher energy costs and a weaker yen, government data showed Thursday.

The country had a deficit of 2.19 trillion yen ($19 billion), the sixth straight month of red ink and the biggest since January 2014 when a 2.80 trillion yen deficit was marked, according to a preliminary report by the Finance Ministry.

The value of overall imports rose 39.6 percent from a year earlier to 8.52 trillion yen, up for the 12th consecutive month and hitting a record high for the third month in a row since comparable data became available in January 1979.

Surging crude oil, coal and liquefied natural gas prices as well as the yen's depreciation against the U.S. dollar amid prospects of monetary tightening by the U.S. Federal Reserve have all contributed to pushing up Japan's value of imports.

The expansion of imports outpaced a 9.6 percent increase in exports to 6.33 trillion yen, an 11th straight monthly rise based on increased unit prices of exported items such as steel and diesel oil.

Auto exports declined 1.0 percent from a year earlier, compared with 17.6 percent growth in December, reflecting the impact of a cutback in output due to the pandemic.

Kazuma Kishikawa, an economist at the Daiwa Institute of Research, cited a resurgence of coronavirus infections in Japan in the reporting month, fueled by the highly contagious Omicron variant, as a reason for the sluggish auto shipments.

"At domestic car parts factories, more workers considered to have been in close contact with infected people were suspended, which forced some major automakers to cut production," Kishikawa said.

By country, exports to China fell 5.4 percent to 1.17 trillion yen, down for the first time in 19 months, mainly due to a drop in plastic and vehicle engine shipments. Imports from Japan's largest trading partner jumped 23.7 percent to a record 2.13 trillion yen.

With the United States, Japan's exports climbed 11.5 percent to 1.12 trillion yen, pushed up by brisk shipments of chip-making equipment. Imports soared 33.4 percent to 781.89 billion yen, underpinned by a rise in medical and petroleum products.

As for the European Union, Japanese exports increased 16.1 percent to 618.04 billion yen, with imports growing 26.2 percent to 870.69 billion yen. Exports to Asia including China totaled 3.58 trillion yen, up 6.3 percent, while imports amounted 4.18 trillion yen, up 29.1 percent.

Looking forward, energy prices could continue to rise amid mounting fears of a possible Russian invasion of Ukraine. But Kishikawa said the impact on Japan's imports could be moderate.

"Japan buys crude oil mainly from Arab producers, and the price of Dubai crude oil is less susceptible to the Ukraine situation than those of Brent and West Texas Intermediate," said Kishikawa.

He added that an increase in Japan's purchase of COVID-19 vaccines will continue to raise the costs of imports until around April, and the trade deficit will gradually shrink thereafter.

All figures were compiled on a customs-cleared basis.