Chinese trade enjoyed surprise growth in June as the world slowly emerges from economy-strangling lockdowns, though officials warned of headwinds for recovery owing to the spread of the pandemic.

The figures come days before the release of data expected to show the world’s number two economy returned to growth in the second quarter following a contraction in the first three months of the year.

The 2.7-percent growth in imports was the first since December and much better than the nine-percent contraction forecast in a Bloomberg News poll, while exports also beat expectations by rising 0.5 percent.

In May, imports had collapsed 16.7 percent and exports retreated 3.3 percent.

Customs spokesman Li Kuiwen told reporters Tuesday that imports and exports showed “signs of recovery and stability” in the second quarter and that China was “forging ahead” with efforts to ensure stability in areas such as employment, foreign trade, and investment.

But he cautioned the external environment is “more grim and complicated” now, with COVID-19 plunging the global economy into a deep recession and international trade and investment experiencing sharp contractions.

In the first half, exports dropped 6.2 percent on-year while imports fell 7.1 percent, official data showed, reflecting the hit from the pandemic, which first surfaced in central China.

ING China economist Iris Pang told AFP agricultural purchases boosted imports and that the push could continue if floods ravaging much of central China persist, threatening food supplies.

“We also see a broad-based recovery in exports,” she said.

China’s economy is expected to have grown in April-June, having shrunk 6.8 percent in the preceding three months as the virus battered the planet.

That was the first quarterly contraction since China began logging such data in the early 1990s.

Beijing’s trade surplus with the United States — a major cause of anger in the White House — narrowed slightly to $29.4 billion in June, down 1.7 percent year-on-year.

Tensions have been rising as the superpowers trade barbs on multiple fronts, including the pandemic and a new security law in Hong Kong.

But Li said the US and China will continue to implement a phase-one trade deal signed in January that marked a truce in their long-running trade war.

Analysts warn, however, that the trade recovery could lose momentum due to weak external demand from renewed lockdowns in key trading partners.

HSBC chief China economist Qu Hongbin said in a recent report that “the gauges for new export orders in China’s purchasing managers’ index… still contracted in recent months”, referring to the key indicator of factory activity.

Imports were likely supported by continued improvement in domestic demand and commodity prices, he added.

Martin Rasmussen of Capital Economics noted that the boost from shipments of medical products and work-from-home equipment, “which are still growing at over 30 percent year-on-year, will continue to fade”.

Risk consultancy SinoInsider cautioned that despite Chinese efforts to rely more on its domestic consumer market, this could be hampered as overall spending power decreases.