Japan's trade deficit more than halved in 2023 to 9.29 trillion yen ($63 billion) from the previous year, as robust auto shipments to the United States lifted exports to a record high while energy imports slumped, government data showed Wednesday.

The United States overtook China as the recipient of the most Japanese exports by value for the first time in four years.

Exports to the United States reached 20.27 trillion yen, up 11.0 percent, while those to China totaled 17.76 trillion yen, down 6.5 percent, according to the Finance Ministry.

Strong export growth helped resource-scarce Japan, hit by surging import costs and a weaker yen that inflated them further, to trim its trade deficit. But it was still in the red for the third straight year.

Overall exports rose 2.8 percent to 100.89 trillion yen, surpassing the 100 trillion yen mark for the first time. It was the highest level since comparable data became available in 1979. Imports dropped 7.0 percent to 110.18 trillion yen.

For December alone, exports hit their highest level on record, underscoring the strength of demand in the United States despite concerns about an economic slowdown linked to its monetary tightening cycle.

Japan's trade balance swung to a surplus of 62.1 billion yen in the reporting month from a year earlier.

"Auto export growth was the major driver but overall shipments were still solid," said Yuichi Kodama, chief economist at the Meiji Yasuda Research Institute.

"That being the case, the sustainability of export growth has come into question because China looks set to see a further economic slowdown and demand will likely weaken in the United States and Europe," Kodama said.

Economists say the yen's persisting weakness against the U.S. dollar will also keep import costs elevated, with the focus on how crude oil and other commodity prices will move amid heightened geopolitical risks in the Middle East.

The value of the yen versus the dollar decreased 7.2 percent last year, reflecting the differing policy positions of the dovish Bank of Japan and the Federal Reserve, which aggressively raised interest rates to curb demand and cool inflation.

Japan saw its trade surplus with the United States increase 34.3 percent to 8.72 trillion yen after exports jumped 11.0 percent to a record 20.27 trillion yen.

It came after Japan's surplus with the world's largest economy reached 1.07 trillion yen last month, the highest for the month of December, helped by strong auto exports.

With another major trading partner China, Japan ran a deficit of 6.65 trillion yen for 2023, up 13.8 percent.

Japan's trade surplus with Asia as a whole, which includes China, shrank 74.6 percent to 508.68 billion yen.

Japan was in the red for the 12th straight year with the European Union, though the deficit fell 55.9 percent to 919.46 billion yen helped by strong exports of cars, motorbikes and machinery.