UPDATE 3-Surprise gain in Japan's machinery orders masks cooling investment outlook

* April core orders +5.2% m/m vs f'cast -0.8% m/m

* Core orders +2.5 pct yr/yr vs f'cast -5.3% yr/yr

* Capex so far resilient to external risks

* But outlook for investment dims as firms wary of trade war (Adds context on corporate Japan, detail)

By Tetsushi Kajimoto and Daniel Leussink

TOKYO, June 12 (Reuters) - Japan's machinery orders unexpectedly rose for a third straight month in April, signalling solid business investment, though analysts expect an intensifying Sino-U.S. trade war and global slowdown to hurt capital spending plans in the coming quarters.

The upbeat data may solidify expectations that a planned sales tax hike will go ahead in October, and offers some support for an economy hampered by faltering exports, slowing corporate earnings and factory activity.

Cabinet Office data released on Wednesday showed core machinery orders, a highly volatile data series regarded as an indicator of capital spending in the coming six to nine months, increased 5.2% in April from the previous month.

It marked the biggest gain since last October, and compared with economists' median estimate of a 0.8% decline in a Reuters poll. In March, orders rose 3.8%.

Capital spending has been a bright spot in the world's third largest economy, driven by investment in high-tech and labour-saving technology to cope with a labour crunch in the ageing society and refurbishing demand for upgrading old plants and equipment.

All the same, Japanese firms may turn cautious about boosting investment if uncertainty over the global economy and the bruising U.S.-China trade dispute persist, analysts say.

Underscoring the pressure on export-reliant Japan, external orders, which do not account for 'core orders' tumbled 24.7% month-on-month in April, reversing from the prior month's 9.0% gain and posting the biggest drop since November 2015. "We think that rising uncertainty over the economic outlook will result in a slowdown in business investment growth over coming quarters," said Marcel Thieliant, senior Japan economist at Capital Economics.

TRADE WAR

Washington and Beijing have been locked in a tit-for-tat tariff war for nearly a year, which has curbed global trade and upended supply chains ranging from Asia to Europe, undermining Japan's exports and factory output.

Investors expect Japanese exporters' earnings will remain under pressure. Japanese companies are likely to report a 1% drop in pre-tax profits this fiscal year through March, Daiwa Securities said last month.

Big companies such as factory-robot makers Yaskawa Electric Corp and Fanuc Corp, as well as Mitsubishi Electric Corp and trading house Mitsui & Co have blamed the trade war and China's slowdown as they cut profit forecasts.