Japan's economy shrank much less than expected in the second quarter as companies made strides in restoring output after the devastating earthquake in March, but a soaring yen and slowing global growth cloud the prospects for a sustained recovery.

Analysts expect the world's third-largest economy to rebound in July-September, probably expanding at the fastest rate among major industrialized nations as exports and factory output return to pre-disaster levels. But growing risks to this scenario could strain a depleted arsenal of policy tools.

Worries that Europe's sovereign debt woes are sparking another global crisis could rob Japan of much-needed export demand, increasing the chance of further yen-selling intervention and monetary easing to secure economic recovery.

If the global economy picks up and demand for Japan's products remains solid, we think the external sector may not be hurt very much, but a worse-than-expected slowdown (globally) could lead to a delay in Japan's economic recovery, even with the pick up from reconstruction efforts, said Satoru Ogasawara, economist at Credit Suisse in Tokyo.

Gross domestic product fell 0.3 percent in the second quarter, less than a median forecast for a 0.7 percent contraction and a 0.9 percent contraction in January-March.

On an annualized basis, the economy contracted 1.3 percent against a median forecast of a 2.6 percent annualized decline. That contrasted with U.S. annualized growth of 1.3 percent in the same quarter.

Companies restocked inventories more than expected after drawing them out in the preceding quarter, while public investment rose for the first time in six quarter thanks to post-quake reconstruction.

Domestic demand, as a result, added 0.4 percentage point to the second-quarter growth, the first positive contribution in three quarters.

Private consumption, which makes up around 60 percent of the economy, eased 0.1 percent in April-June, a much smaller drop than expected due to one-off factors such as the switch to digital broadcasting leading to strong television sales.

But some analysts took tepid growth in corporate capital spending as a sign of companies' wariness about boosting investment due to the yen's rise, stagnating global demand and uncertainty over Japan's policy outlook.

Corporate capital spending rose 0.2 percent, less than the market forecast of a 0.5 percent increase.

External demand, or net exports, pushed down GDP by 0.8 percentage point, as the disaster prevented some Japanese manufacturers from shipping goods abroad.

Japan intervened in the currency market and eased monetary policy earlier this month, aiming to curb a yen rise near record highs that threatened to derail the export-reliant economy's recovery from the earthquake and tsunami.

Analysts expect the economy to emerge from recession in July-September, after three straight quarters of contraction, as manufacturers shake off supply constraints and reconstruction demand kicks in.

But the soaring yen and slowing global growth pose risks to the BOJ's forecast that the economy will resume a moderate recovery in autumn.

(Additional reporting by Leika Kihara and Kaori Kaneko, writing by Leika Kihara, editing by Chris Gallagher)