Japan's trade deficit in the first half of fiscal 2023 declined 75.1 percent to 2.72 trillion yen ($18 billion), as imported energy costs fell after surging amid Russia's war in Ukraine and a tumbling yen, while exports grew to a record high, government data showed Thursday.

The resource-scarce nation was in the red for the fifth straight year on a first-half basis, with the outlook for export growth increasingly uncertain amid weakening demand in China and aggressive monetary tightening in the United States and Europe.

Imports came to 52.96 trillion yen, down 12.4 percent, as the value of crude oil, liquefied natural gas, and coal all declined. Exports stood at a record 50.24 trillion yen, up 1.4 percent, helped by robust auto shipments to the United States, the Finance Ministry said in a preliminary report.

The Israel-Hamas war has heightened tensions in the oil-producing Middle East, leaving financial markets on edge over geopolitical risks.

As most of Japan's crude oil imports come from the region, analysts say higher prices, coupled with the yen's persistent weakness, may mean bigger trade deficits for the nation in the coming months.

Japan registered a massive 10.91 trillion deficit in the April-September period of 2022, the highest since comparable data became available in 1979, underscoring the vulnerability of a nation heavily reliant on imports to meet its domestic energy needs.

"U.S. economic growth remains solid for now. The economy may be headed for a soft landing but growth of Japan's export to the United States will likely slow sooner or later. And there is China, whose outlook is far from optimistic because of real estate problems," said Yuichi Kodama, chief economist at Meiji Yasuda Research Institute.

"For Japan's trade data, how energy prices will move (amid the Middle East tensions) is an important factor to watch at a time when we can't expect a reversal of yen weakness as U.S. interest rates will remain elevated," Kodama added.

Auto exports reached a record level, buoyed by robust U.S. demand as chip shortages that had forced automakers to cut output eased.

Japan's exports to the United States grew 10.6 percent to a record 10.08 trillion yen, while imports fell 6.0 percent to 5.59 trillion yen, translating into a 4.49 trillion yen surplus.

Japan's trade deficit with China continued to expand, hitting 2.87 trillion yen as exports fell more than imports, in a worrying development as the latter's recovery from the COVID-19 fallout has been lackluster and real estate woes persist.

Exports declined 8.2 percent to 8.91 trillion yen, compared with imports that dropped 6.2 percent to 11.77 trillion yen.

With Asia, including China, Japan's trade surplus shrank by 23.4 percent to 989.74 billion yen, and its deficit with the European Union more than halved from a year earlier to 401.44 billion yen.

In September alone, Japan eked out a 62.44 billion yen trade surplus as exports grew for the first time in three months.

Car shipments to the United States and Europe propelled overall exports to a record high of 9.20 trillion yen, up 4.3 percent. Imports dropped 16.3 percent to 9.14 trillion yen.

Food exports to China tumbled 58.0 percent, partly reflecting its ban on seafood imports from Japan following the release of treated radioactive water from the crippled Fukushima Daiichi nuclear power plant. No further breakdowns were released.

Japan ran a 955.07 billion yen trade surplus with the United States but recorded a deficit with China of 570.96 billion yen for the 30th straight month of red ink, the data showed.

Japan's economy has received a boost from export growth in recent quarters, with a revival of inbound tourism also lending support.

In the six months to September, the dollar was 5.6 percent higher against the yen, as the Bank of Japan has stuck with ultralow rates while the Federal Reserve has raised interest rates to tame inflation.

A weak yen increases import costs, a major factor accelerating Japan's inflation for over a year.

"Given recent rises in crude oil prices and the yen's depreciation, Japan will likely remain in the red for some time," said Kota Suzuki, an economist at Daiwa Securities.

Related coverage:

Japan's trade deficit falls to 930.5 bil. yen, exports to China slump

Japan back in red with July deficit of 78.7 bil. yen as exports sag