The trade surplus grew to €19.7 billion ($30.4 billions), from a revised €14.3 billion in May, the federal statistics office Destatis said in a statement.
Germany's current account, the widest measure of trade and financial transactions with other countries, showed a surplus of €18.5 billion, more than double the May level of €7.7 billion, Destatis said.
Analysts polled by Dow Jones Newswires had forecast a trade surplus of €15.0 billion and a current account surplus of €12.0 billion. German exports jumped by an unadjusted 7.9 percent in June from the same month a year earlier, while imports increased by 5.3 percent. When corrected for seasonal and other calendar effects, exports were up by 4.2 percent to €85.9 billion, while imports had slipped by 0.1 percent to €67.8 billion.
The figures were good news following a string of numbers that had indicated the German economy was slumping heavily after initially appearing to have withstood a global slowdown.
On Wednesday, data showed that industrial orders had fallen in June for a record seventh month in a row, suggesting that trade figures in the coming months were likely to show weaker exports, the main engine of economic growth. A report in the Sueddeutsche Zeitung on Tuesday quoted government experts as saying that in the second quarter of 2008, the German economy had contracted by around 1.0 percent. Official figures on the second quarter will be published on August 14.
UniCredit economist Andreas Rees sounded a cautious note, however, saying that although exports in June rose at the strongest pace in nearly two years, there was "no reason to celebrate."
"Looking at the medium-term trend, the outlook for exports is really bleak," he said.
In June 2007 new orders from other members of the eurozone - the most important marker for German firms - rose by almost 37 percent. But one year later, they nosedived by 25 percent, Rees said.