A 10-day holiday for the new emperor boosted the Japanese economy [AFP]

Japan's economy grew at a faster-than-expected clip in the second quarter, official data showed on Friday, helped by celebrations to usher in a new imperial era.

Gross domestic product (GDP) in the world's third-biggest economy grew 0.4 percent from the previous quarter, the Cabinet Office said, beating analysts' median forecast of 0.1 percent.

The third straight period of expansion will also bolster Prime Minister Shinzo Abe's determination to push through a controversial sales tax hike in October despite warnings it could weigh on growth.

Shoppers are rushing to make purchases before the rate rises from eight percent to 10 percent on October 1 and this boost for consumption also helped push GDP higher, economists said.

An unprecedented 10-day holiday for the enthronement of Emperor Naruhito, which kicked off a new imperial era in Japan, also pepped up the figures, according to analysts.

However, trade frictions between the US and China weighed on exports and corporate spending in some sectors such as machinery, said Yuichiro Nagai, senior economist at Mizuho Securities.

"But investments in software, research and development, and construction were good," he told AFP.

Nagai said a rush by consumers to buy before the sales tax hike will likely become even more pronounced in the July-September quarter, helping Japan log another quarter of growth.

And while the economy would likely contract in October-December due to the higher tax, it should rebound next year and avoid slipping into a recession, Nagai said.

"There is uncertainty over where the trade war will go... With the US presidential election coming next year, however, I believe the main scenario is that they will find a compromise plan" later this year, he said.

- 'Additional monetary easing' -

The last time Japan hiked its sales tax, in 2014, the result was a slump in consumption and the wider economy and some economists have warned that now is not the time to raise the rate amid uncertainty over global trade and Brexit.

But Tokyo has vowed to go through with the plan unless there is a crisis on the level of the 2008 financial meltdown and Abe has promised countermeasures to cushion the blow on the economy.

SMBC Nikko Securities chief market economist Yoshimasa Maruyama said the Japanese economy would likely expand further in the July-September period but warned it could slide into a mild recession in October-December as the global economy slows.

"By the time autumn comes, debates for a supplementary budget will start and calls for additional monetary easing will get louder," he said in a report released ahead of the GDP announcement.

But Naoya Oshikubo, senior economist at Sumitomo Mitsui Trust Asset Management, was not so gloomy.

"Going forward, central banks are expected to continue easing, and the Chinese government will likely announce fiscal measures, resulting in a global economic recovery, which should help Japan maintain its momentum," Oshikubo said in a report.

Besides the planned tax hike, the impact from trade frictions between Japan and South Korea could be a headwind, he said.

"But both should be limited in their effects," he said as the affected goods make up only a fraction of Japanese exports.