US economic growth surged in the first three months of the year to 3.2% as the threat of a trade war with China forced businesses to stockpile at the fastest rate since 2015.

Figures from the Department of Commerce showed that a jump in hoarding raw materials and finished goods and an increase in government investment overcame weak consumer spending, a drop in housebuilding and low business investment to send GDP growth well ahead of the 2.2% in the last quarter of 2018.

Exports, which have proved volatile in recent quarters in response to threats of a trade war between the US and China, surged and imports declined to add 1.03 percentage points to GDP after being neutral in the fourth quarter.

The improvement dispelled concerns the US economy was heading into recession as early as the summer, as some analysts had feared,after a slowdown last year.

But analysts said the Federal Reserve, which has put interest rate hikes on hold, was unlikely to view the figures as the beginning of an economic boom and reverse its current policy.

In January, the US central bank suspended its three-year push to tighten monetary policy, saying it would “pause” further rate hikes this year. The Fed increased borrowing costs four times to a range of 2.25 to 2.5% in 2018, well above the level of base rates for most other major economies.

The central bank is more likely to focus on a measure of domestic demand, which increased by only 1.3%, the slowest since the second quarter of 2013, after increasing by 2.6% in the last quarter.

Growth in consumer spending, which accounts for more than two-thirds of US economic activity, was also weak, growing by just 1.2% from the previous 2.5%. Business investment slowed sharply, rising at only at a 0.2% rate, the slowest since the third quarter of 2016.

Reports from China show that the world’s second largest economy has arrested last year’s decline, though many analysts believe the better outlook will prove temporary and growth will be lower this year than in 2018.

European manufacturing has slumped in recent months and Japanese output has slowed, marking the US out as the only major economy maintaining high levels of output growth.

The effect of stockpiling in the US has also buoyed activity in the UK, where the uncertainty over Brexit negotiations has unnerved businesses and encouraged them to hoard raw materials.

In April, British factories have stockpiled at the fastest pace since records began in the 1950s amid reports they were increasingly downbeat about their prospects.

A survey by the Confederation of British Industry found expectations for export orders in the next three months fell to their lowest level since mid-2009.