The German economy grew at its strongest rate in more than a year in the second quarter, beating forecasts thanks to demand among both consumers and businesses.

The economy expanded by 0.7%, seasonally-adjusted preliminary figures showed today.

It was more than the median forecast in a Reuters poll of economists for expansion of 0.6% and was the biggest quarterly rise since the first quarter of 2012. 

Germany only narrowly avoided recession earlier this year. 

The better-than-expected figure, released five weeks before a federal election, will be welcome news for Chancellor Angela Merkel who is seeking a third term in the vote on September 22. Her government expects growth of 0.5% this year.

Separate data showed the euro zone as a whole growing at 0.3% in the quarter, ending the bloc's longest contraction which began in late 2011.

"The economic upturn is continuing. There is every reason for people in Germany to look to the future with optimism. We have overcome the weak phase of the winter half-year 2012/2013 excellently," German Economy Minister Philipp Roesler said.

While Europe's economic powerhouse steamed ahead during the early years of the euro zone crisis, it slowed last year and even contracted in the fourth quarter as exports languished and investment was sluggish.

But investments picked up significantly between April and June, largely due to weather-related catch-up effects after an unusually long and cold winter, while net exports also made a positive contribution to growth, the Statistics Office said.

Investments in machines and equipment - an indicator of future economic growth - rose for the first time in around one and a half years, the Office said.

But economists warned that weak investments remained a challenge for the economy. German firms have also been downbeat about export prospects during the current earnings season. Synthetic rubber maker Lanxess, for example, warned of fragile sentiment in markets like China and Brazil as well as Europe.

Germany corporate results have been a mixed bag. Of Germany's 30 biggest companies, just over a third reported second-quarter financial results that missed analyst expectations, while fewer than a third beat consensus.

The German Statistics Office revised downwards the figure for the first quarter of 2013 to show stagnation of 0% after riginally reporting an expansion of 0.1%.

The Economy Ministry, the Bundesbank and economists have all said growth will likely be more moderate in the second half given that the bumper second quarter growth was partly due to catch-up effects and Germany still faces a tough international environment.

The BDI federal industry association today cut its forecast for German 2013 growth to 0.5% from its January estimate of 0.8%, saying the export-oriented economy could not decouple from a global slowdown.