German imports and exports unexpectedly shrunk in July, with a sharp export contraction causing a surprise narrowing in Germany's trade balance.

Federal Statistical Office data showed seasonally adjusted exports fell by 2.6% - analysts had expected about 0.3% growth - whereas imports fell by 0.7%, as against expectations for a 0.8% rise.

On the year exports slumped by 10% and imports shriveled by 6.5%.

The foreign trade balance shrunk to €19.4 billion ($21.9 billion) from €21.4 billion in June, as against expectations for a balance of €22 billion.

The Federal Statistical Office said the pace of German exports to other EU countries fell by 7% in July, while imports from the region fell by 4.5%. The falls were slightly narrower for trade with other eurozone countries.

German trade outside the 28-nation EU fared worse, with exports plunging by 13.8% and imports by 10.1%.

Faltering German exports amid lackluster worldwide growth and emerging-market volatility has long been a drag on German growth. But the sharper-than-expected export fall challenges expectations of a second-half pickup in German trade with the rest of the world, and the surprise - albeit small -import decline suggests domestic demand isn't robust enough to step into the breach.

The trade data come in a week that the statistics office reported weaker-than-expected industrial output and manufacturing production for July.

But the euro held firm against the dollar after the figures and was recently up 0.11% at $1.1272.

Against the pound it was down 0.04% at £0.8467. A post-Brexit-vote rise in the euro against the U.K. currency has eroded Germany's competitive position with one of its main trading partners.

The European Central Bank on Thursday stood pat on rates and unexpectedly refrained from extending its asset repurchase program, which expires in March. But ECB boss Mario Draghi left open the option for further monetary easing if barely-there eurozone price growth continues.