Japan has bounced back from a poor start to the year.

The world's third-largest economy grew at an annualized rate of 1.9% in the second quarter, according to government figures released Friday.

Boosted by a jump in spending by consumers, the performance beat economists' expectations and marks a recovery from a contraction in the first quarter of the year.

It means Japan avoided slipping into a recession, which is commonly defined as two consecutive quarters of economic contraction. But the country is likely to struggle to grow strongly in the coming quarters.

"Growth isn't as vigorous as last year," Marcel Thieliant, senior Japan economist at research firm Capital Economics, said in a note to clients.

Related: EU and Japan sign trade deal covering a third of the world's economy

The economy's contraction in the first quarter snapped its longest streak of growth since the boom days of the late 1980s. But the two-year expansion has stretched resources in Japan, which is struggling with problems that include a rapidly aging population and persistently low inflation.

"Firms are facing severe labor and capacity shortages that make it difficult to sustain above-trend growth," Thieliant said. He predicted that "activity will remain sluggish for now."

Japanese companies that sell goods overseas are facing uncertainty from escalating global trade tensions. The country's big automakers, including Toyota (TM), Nissan (NSANF) and Honda (HMC), are worried about US President Donald Trump's threats to impose tariffs on car imports.

Japan's economy has another danger on the horizon: the government is scheduled to hike the sales tax in the fall of next year. The last time it did so, Japan plunged into a recession.

Consumers are expected to give the economy a lift ahead of the increase by rushing to make purchases, but "a renewed slump in spending once the tax has been raised is all but guaranteed," Thieliant said.