The Federal Statistics Office confirmed a preliminary gross domestic product contraction of 0.1% quarter-on-quarter from April to June after a 0.4% expansion in the first three months of the year.
The outlook for the German economy is uncertain as sentiment indicators point to a bumpy road ahead and most economists expect another quarter of contraction which would be a technical recession.
Exports fell more strongly than imports in the second quarter which meant that net trade deducted 0.5 percentage points from overall economic expansion.
Construction investment was also a drag, falling 1.0% on the quarter.
Household spending, state expenditure and private-sector investment in machinery and equipment all increased, but they were not strong enough to counter the massive drag of net trade.
"The details of the growth components show that the contraction was almost exclusively driven by weak exports," Carsten Brzeski from ING said, adding that the GDP figures showed that not everything was bad.
"Some relief from trade could easily lead to a rebound towards the end of the year. Fiscal stimulus could boost confidence and improve structural growth in the years ahead."
Senior government officials have hinted that Berlin is mulling more fiscal stimulus linked to a comprehensive package of climate protection measures. Some suggested the government could even take on new debt to finance those steps.
Despite the mixed performance of the economy in the first six months of the year, the German state managed to record a whopping budget surplus of 45.3 billion euros ($50.5 billion) from January to June, the data showed.
That represents a surplus of 2.7% of economic output.
The federal government recorded a surplus of 17.7 billion euros, the 16 federal states 12.7 billion euros, municipalities 7.1 billion euros and social security system 7.7 billion euros.
The Ifo business sentiment survey showed on Monday that business morale deteriorated more than expected in August to hit its lowest in nearly seven years, in a further sign that escalating trade disputes are pushing the German economy towards recession.
The calendar-adjusted yearly growth rate eased to 0.4% in the second quarter from 0.9% in the first, Tuesday's data showed.