Japan's trade deficit decreased to 187.1 billion yen ($1.69 billion) in May from 856.7 billion yen a year earlier thanks to a big jump in exports - mainly machinery, the Ministry of Finance said Wednesday.

Economists had predicted a 91.2 billion yen deficit.

Exports rose 49.6% year on year to 6.26 trillion yen while imports rose 27.9% to 6.45 trillion yen.

For the first five months of the year the trade gap has narrowed to 996.69 billion yen from 1.20 trillion yen in the same period of 2020, the ministry said.

Exports posted a third consecutive month of growth and the steepest since April 1980. There were signs "a recovery in global trade gained strength." Sales of machinery rose 40.4% while transport equipment sales rose 118.9% - mainly tanks to motor vehicles, which were up 135.5%.

There were rises in shipments of electrical machinery - up 32.9%.

China bought 23.6% more goods year on year from Japan in the month and the U.S. 87.9% more.

Imports increased to a more-than-expected 6.49 trillion yen in May. The market had predicted a 26.6% rise after a 12.8% gain in April. Imports have been growing for four consecutive months now "as domestic demand accelerated in the wake of the pandemic," the ministry said.

"Despite the spectacular growth rates in May the rebound in exports is showing signs of slowing," according to Capital Economics Japan economist Tom Learmouth.

"We doubt external demand will provide much of a tail wind to growth over the coming months as global consumer goods demand weakens in the wake of vaccine rollouts. Meanwhile, the muted rise in machinery orders in April supports our view that business investment will have trodden water this quarter."

"As import prices were up a further 3.0% month over month last month we estimate that import volumes fell by 2.3% month over month.

"But we think business investment is set for a strong rebound in the second half of the year as the impact of the fast-accelerating vaccine rollout comes through."