Japan logged a record trade deficit of ¥8.17 trillion in fiscal 2012, the second straight year of red ink, as a territorial spat with China and the European debt crisis stifled exports, with energy imports surging due to the halt of nuclear power plants, the government said Thursday.

It was the first time that the trade balance has remained in deficit for two years in a row since 1980, when the country was hit by the second oil crisis, the Finance Ministry said.

Among comparable data available since fiscal 1979, the previous largest trade deficit on a business year basis was ¥4.42 trillion logged last fiscal year.