Exports enjoyed a seven percent rise in June compared to the previous month - the highest rise for nearly three years - while imports were up 6.8 percent, seasonally-adjusted figures from the Federal Statistics Office said.
"Today's figure indicates that the German export champion managed a tremendous comeback recently," said Andreas Rees, the head German economist at UniCredit Research.
The total trade surplus, of €12.2 billion ($17 billion), surprised analysts surveyed by Dow Jones Newswires, who were expecting a weaker result of €10.7 billion.
Nevertheless, the trade surplus from January to June this year was 44.8 percent weaker than the same period in 2008, demonstrating that Germany still has some way to go to climb out of its deepest recession in six decades. And on a year-on-year basis, the trade surplus in June was down 22.3 percent.
The trade data are the latest in a series of positive surprises for Germany, one of the world's leading exporters.
On Thursday, the economy ministry reported that industrial orders had jumped by 4.5 percent in June in following a 4.4-percent rise in May, adding that prospects for the key sector had improved.
In addition, so-called "soft" data, such as business and consumer confidence surveys are pointing to brighter times ahead in Germany. "Definitely more is in the pipeline in the months to come as indicated by surging foreign new orders," said Rees.
The government has so far stuck to its gloomy projection of an economy shrinking by a record six percent this year, before creeping back into the black in 2010 with a meagre 0.5 percent growth. But with the German economy so heavily dependent on exports - estimates say around 40 percent of output relies on exports - Friday's data will cheer Chancellor Angela Merkel, who is gearing up for elections on September 27.
And the recovery in German trade is also a positive signal that the world economy is gradually recovering from its worst slump since the Great Depression.
European Central Bank President Jean-Claude Trichet told RTL radio earlier Friday he believed that the world economy was "coming out of the period of free fall."
Nevertheless, he warned: "The zone of uncertainty in which we have been since the crisis intensified in mid-September 2008 is not yet behind us."