Germany and France enjoyed a shock return to economic growth in the second quarter of the year, data showed on Thursday, ending their recessions earlier than many policymakers and economists had expected.

German gross domestic product rose by 0.3 percent in the second quarter, bringing an end to the country's deepest recession since World War Two and boosting hopes of recovery in the broader euro zone.

French GDP also grew by 0.3 percent in the second quarter. The consensus in a Reuters poll of economists had predicted a 0.3 percent quarterly contraction in both countries.

The data is very surprising. After four negative quarters France is finally coming out of the red, French Economy Minister Christine Lagarde told RTL radio.

Germany suffered a calamitous 3.5 percent contraction in the first quarter of this year to cap four quarters of decline while the French economy shrank by 1.3 percent.

Euro zone GDP data are due at 0900 GMT with the risks to forecasts of a 0.5 percent quarterly contraction now clearly to the upside.

Taking the upward surprise in the German and French data together, the euro zone economy should have been roughly flat in Q2, said Nick Kounis, economist at Fortis.

Market response to the figures was instant.

European shares and the euro climbed while euro zone government bond futures opened down after the economy figures fueled optimism about the outlook for the single currency bloc's economy.

RECOVERY AT LAST?

Evidence is mounting that the worst of the damage wrought by a global financial crisis, which began with a U.S. housing market meltdown in 2007 and took a turn for the worse last year when U.S. bank Lehman Brothers collapsed, is now over.

The recession has ended. Not just in Germany. The post-Lehman global confidence shock has receded. Firms are investing again, said Joerg Kraemer at Commerzbank.

The Federal Reserve said on Wednesday the U.S. economy was showing signs of leveling out two years after the onset of the deepest financial crisis in decades.

It was the first time since August 2008 the committee's statement had not characterized the economy as contracting, weakening, or slowing.

The Bank of England struck a slightly more subdued tone in its quarterly inflation report on Wednesday, saying Britain's recession would end early next year but that the economy would take a long time to recover properly.

Britain now looks in relatively poor shape, its economy having shrunk by 0.8 percent in the second quarter.

Italy, the euro zone's third largest economy, reported last week its economy dropped by 0.5 percent in the second quarter.

Data from Austria on Thursday showed it shrank by 0.4 percent in the second quarter while the Netherlands contracted by 0.9 percent.

Year-on-year, Germany shrank by 7.1 percent in the second quarter, the data showed, following a 6.4 percent drop in Q1.

The government expects the economy to contract by some six percent this year. However, the Economy Ministry had already said the economy probably stabilized in the second quarter.

Lagarde said solid exports and strong public sector investment, fueled by government stimulus measures to counter the global economic crisis, were bolstering growth in France.

REASONS TO BE CAUTIOUS

But experts remain cautious with budget deficits spiraling under the weight of government stimulus packages and unemployment levels set to climb for some time.

The main risk for Germany is a sharp rise in unemployment. If firms decide to start firing people in the autumn rather than putting them on shorter hours, it's going to have a negative impact on wages and hit consumption, said Christian Dreger of the DIW economic institute.

And banks in many countries remain in poor shape and reliant on state support.

The question is how lasting it will be. There are lots of problems we haven't solved. In particular, the banking sector is still dependent on the state umbrella, said Jens-Oliver Niklasch, analyst at LBBW.

As long as it's not clear that the banks' capital base is robust, we can't assume that the crisis is over.

But if nothing else, the prospect of a 1930s-style depression appears to have been banished.

It's good to see that we're not in a 1929 or 1930s type situation of total collapse, said Marc Touati at Global Equities in Paris. But there are risks on growth ... With a stronger euro, little room to further cut interest rates and stimulus packages already running out, what is going to sustain us in coming months?

(Writing by Mike Peacock; editing by Chris Pizzey)