Japan's economy returned to growth in the second quarter, pulling out of its longest recession since World War Two, but analysts warned of a rocky road ahead as the nascent recovery was based on short-term stimulus efforts around the world.

The growth was mostly in line with forecasts and added to evidence that Japan was clawing back after being the hardest hit among the major economies due to its reliance on exports.

Growth in the world's No.2 economy is likely to continue in the coming quarters as companies restock inventories due to exports and government stimulus spending around the world.

The ruling party is hoping the figures will help it ahead of an election it looks likely to lose, but political analysts said the data was unlikely to turn the tide.

Economists and policymakers were also wary about the outlook for next year as exports, the biggest contributor to April-June growth, may slow as the effect of stimulus measures wear off.

Today's data was driven by stimulus steps in Japan and overseas, so Japan's economy is far from self-sustaining growth, said Kyohei Morita, chief Japan economist at Barclays Capital.

The growth level for the July-September quarter will likely be similar to that of April-June, and the pace of growth is expected to slow down thereafter as the effects of government stimulus run their course.

Gross domestic product grew 0.9 percent in April-June, slightly short of a median market forecast of a 1.0 percent increase. That puts Japan in the first camp of G7 countries that have pulled out of recession, along with Germany and France.

It compared with a 0.3 percent contraction in the United States in the same quarter. The euro zone economy shrank 0.1 percent after a 2.5 percent fall in the first three months.

The expansion, the first in five quarters, followed a revised 3.1 percent contraction in January-March and a record 3.5 percent fall in the final quarter of 2008.

On an annualized basis, it grew 3.7 percent from the first quarter, the fastest since January-March 2008.

BOJ REMAINS CAUTIOUS

Inventories cut 0.5 percentage point from GDP in April-June, more than double a 0.2 percentage-point deficit the previous quarter. This suggests inventories will contribute to growth in the July-September quarter as companies stockpile goods to meet a pick-up in demand at home and abroad, economists say.

But the rise in output isn't likely to translate into higher corporate spending as manufacturers are still operating at around 70 percent of capacity, they say.

Bank of Japan officials who spoke to Reuters after the data weren't very optimistic about the outlook, citing weakness in capital spending and doubts about how long the rise in consumer spending will last.

The April-June data also showed that the domestic demand deflator, an indicator of price trends, fell 1.7 percent from the same period a year earlier, faster than a 1.0 percent annual decline in the previous quarter as deflationary pressures mount.

Market participants expect the BOJ to maintain interest rates at the current 0.1 percent at least until early 2011.

Economists expect Japanese GDP to grow 0.4 percent in July-September from the previous quarter, followed by a 0.5 percent increase in October-December, a Reuters poll showed.

But they say the recovery could lose momentum later this year as a temporary boost from government stimulus steps peters out.

The yen initially slipped and JGB futures edged up shortly after the GDP release, but the data had little sustained impact.

External demand, the balance of exports and imports, added 1.6 percentage points to April-June GDP due in part to China's $585 billion stimulus package and other such spending rolled out by governments around the world to combat the global recession.

Tokyo's stimulus steps helped private consumption, which accounts for about 60 percent of the economy, to rise 0.8 percent and public investment to increase 8.1 percent.

Capital spending fell 4.3 percent, smaller than a 5.9 percent drop expected by economists but marking the fifth straight quarter of slump as companies remain cautious about the outlook for global final demand.

Prime Minister Taro Aso, in a debate with rival party leaders on Monday, touted the positive figures as the result of his government's efforts, but acknowledged that ordinary citizens might not yet feel the effect.

Analysts doubted the data would help Aso's ruling Liberal Democratic Party much, however.

This won't be a negative factor (for the LDP) but if you ask me if it'll be a great positive factor, I don't think it matters much, said Tomoaki Iwai, political science professor at Nihon University.

($1=95.14 Yen)

(Additional reporting by Leika Kihara, Rie Ishiguro, Yoshiyasu Shida and Shigeo Kodama; Editing by Hugh Lawson)