That resulted in a trade balance of $5.15 billion, wider than Reuters' estimate for $2.78 billion and marking the third month of surplus.
The yen was 0.6 percent higher around 99.73 per dollar following the data, bringing its year-to-date gains to more than 17 percent. A stronger currency is a headache for domestic exporters as it eats into repatriated earnings and makes goods of Japanese competitors, such as South Korea, more attractive in comparison.
"There were no big surprises here. Keeping in mind export volumes in June did well so there was an anticipated pullback to these numbers," said Kathy Matsui, managing director and chief Japan strategist at Goldman Sachs Japan.
"The crucial thing is that the trade surplus is still in positive territory, so the current account remains large, which is one of the reasons why the yen has remained strong."
While the larger-than-expected decline in imports was surprising, Marcel Thieliant, senior Japan economist at Capital Economics, noted that the drag from cheaper energy costs on import prices began to fade.
"In contracted-currency terms, import prices were falling by 10.9 percent on-year last month, the slowest decline since December 2014."
Foreign exchange strategists are widely betting for the yen to resume its weakening trend, which should see the export and imports recover soon.
"But with external demand sluggish, trade volumes are unlikely to stage a strong rebound," said Thieliant.
—Follow CNBC International on Twitter and Facebook.