FRANKFURT - Germany's trade surplus beat expectations to shrink only slightly in June after a return to growth in exports, official figures showed on Tuesday.

The trade surplus is watched closely as a gauge of an economy's strength, and had shrunk unexpectedly in May as Germany sold less abroad.

June saw Europe's largest economy sell 21.7 billion euros ($24 billion) more goods than it bought abroad, a slight decrease from May's 22.2 billion, the federal statistics office Destatis reported.

Analysts surveyed by Factset had expected the surplus to shrink much more quickly to 17.5 billion euros.

Compared with the previous month, exports grew by 0.3 percent to 99.8 billion euros in seasonally-adjusted terms in June.

Meanwhile imports grew faster, by 1.0 percent, to 78.2 billion euros as Germans bought more from abroad.

In unadjusted terms, exports grew by 1.2 percent compared with June 2015 to 106.8 billion euros, driven by a 6.0-percent increase in sales to fellow EU members outside the eurozone.

By contrast, sales to eurozone countries grew only slightly compared with the same month last year, by 0.1 percent, while sales to non-EU nations shrank by 0.4 percent.

Released one day after industrial production figures showed June rounding off a weak three months, the trade data is unlikely to raise expectations for Friday's preliminary estimate of economic growth in the second quarter.