The figures, which confirmed estimates made earlier in August, mark the first time Germany has grown since the first quarter of 2008 and are likely to boost Chancellor Angela Merkel's campaign less than four weeks ahead of general elections on September 27.
"The economic development in the second quarter of 2009 was supported by private and government expenditure ... positive impulses also came from construction," the statistics office said in a statement.
However, exports, the driving force of the German economy, were down 1.2 percent compared to the first quarter and imports slumped by 5.1 percent.
Despite the broadly positive figures, analysts warned against any early celebrations.
Carsten Brzeski at financial institution ING said the boost in growth was mainly due to the government's two huge stimulus packages, worth a combined €81 billion ($116 billion).
"Today's numbers are primarily the result of the government's economic rescue package plus some free-riding on other countries' stimulus measures," he said in a research note.
"The German economy is still on a drip, getting infusions from policymakers. The coming weeks and months look good but some doubts remain whether the economy can already stand on its own feet," he said.
"The recession is over but not all that glitters is gold."
Despite the caution, the positive growth figures are the latest in a series of economic data that suggests Germany might bounce back relatively quickly from a deep and painful recession.
Last week, a survey showed that investor confidence was soaring and business confidence is also pointing to brighter times ahead. Industrial orders have also shown impressive growth in recent months.
Merkel, whose Christian Democrats (CDU) are riding high in the polls, said recently that the worst is over for the German economy but that a bumpy road lies ahead.