BEIJING (Reuters) - China’s massive export engine sputtered for the second year in a row in 2016, with shipments falling in the face of persistently weak global demand and officials voicing fears of a trade war with the United States that is clouding the outlook for 2017.

Container boxes are seen at the Yangshan Deep Water Port, part of the Shanghai Free Trade Zone, in Shanghai, China September 24, 2016. REUTERS/Aly Song/File Photo

In one week, China’s leaders will see if President-elect Donald Trump makes good on a campaign pledge to brand Beijing a currency manipulator on his first day in office, and starts to follow up on a threat to slap high tariffs on Chinese goods.

Even if the Trump administration takes no concrete action immediately, analysts say the specter of deteriorating U.S.-China trade and political ties is likely to weigh on the confidence of exporters and investors worldwide.

The world’s largest trading nation posted gloomy data on Friday, with 2016 exports falling 7.7 percent and imports down 5.5 percent. The export drop was the second annual decline in a row and the worst since the depths of the global crisis in 2009.

It will be tough for foreign trade to improve this year, especially if the inauguration of Trump and other major political changes limit the growth of China’s exports due to greater protectionist measures, the country’s customs agency said on Friday.

“The trend of anti-globalization is becoming increasingly evident, and China is the biggest victim of this trend,” customs spokesman Huang Songping told reporters.

“We will pay close attention to foreign trade policy after Trump is inaugurated president,” Huang said. Trump will be sworn in on Jan. 20.

China’s trade surplus with the United States was $366 billion in 2015, according to U.S. customs data, which Trump could seize on in a bid to bring Beijing to the negotiating table to press for concessions, economists at Bank of America Merrill Lynch said in a recent research note.

A sustained trade surplus of more than $20 billion against the United States is one of three criteria used by the U.S. Treasury to designate another country as a currency manipulator.

China is likely to point out that its own data showed the surplus fell to $250.79 billion in 2016 from $260.91 billion in 2015, but that may get short shrift in Washington.

“Our worry is that Trump’s stance towards China’s trade could bring about long-term structural weakness in China’s exports,” economists at ANZ said in a note.

“Trump’s trade policy will likely motivate U.S. businesses to move their manufacturing facilities away from China, although the latter’s efforts in promoting high-end manufacturing may offset part of the loss.”

On Wednesday, China may have set off a warning shot to the Trump administration. Beijing announced even higher anti-dumping duties on imports of certain animal feed from the United States than it proposed last year.

“Instead of caving in and trying to prepare voluntary export restraints like Japan did with their auto exports back in the 1980s, we believe China would start by strongly protesting against the labeling with the IMF, but not to initiate more aggressive retaliation ... immediately,” the BofA Merrill Lynch Global Research report said.

“That said, even a ‘war of words’ could weaken investor confidence not only in the U.S. and China, but globally.”

CHINA’S DECEMBER EXPORTS FALL

China’s December exports fell by a more-than-expected 6.1 percent on-year, while imports beat forecasts slightly, growing 3.1 percent on its strong demand for commodities which has helped buoy global resources prices.

An unexpected 0.1 percent rise in shipments in November, while scant, had raised hopes that China was catching up to an export improvement being seen in some other Asian economies.

China reported a trade surplus of $40.82 billion for December, versus November’s $44.61 billion.

While the export picture has been grim all year, with shipments rising in only two months out of 12, import trends have been more encouraging of late, pointing to a pick-up in domestic demand as companies brought in more raw materials from iron ore to copper to help feed a construction boom.

China imported record amounts of crude oil, iron ore, copper and soybeans in 2016, plus large volumes of coal used for heating and in steelmaking.

“Trade protectionism is on the rise but China is relying more on domestic demand,” said Wen Bin, an economist at Minsheng Bank in Beijing.

Prolonged weakness in exports has forced China’s government to rely on higher spending and massive bank lending to boost the economy, at the risk of adding to a huge pile of debt which some analysts warn is nearing danger levels.

Data next Friday is expected to almost certainly show that 2016 economic growth hit Beijing’s target of 6.5-7 percent thanks to that flurry of stimulus.

But signs are mounting that the red-hot property market may have peaked, meaning China may have less appetite this year for imports of building-related materials.

“It is hard to see what could drive a more substantial recovery in Chinese trade,” Julian Evans-Pritchard, China Economist at Capital Economics, wrote in a note.

“Further upside to economic activity, both in China and abroad, is probably now limited given declines in trend growth. Instead, the risks to trade lie to the downside...,” he said, saying the chance of a damaging China-U.S. trade spat has risen since Trump’s appointment of hardliners to lead trade policy.

A decline in China’s trade surplus in 2016, to just under $510 billion from $594 billion in 2015, may also reduce authorities’ ability to offset capital outflow pressures, which have helped drive its yuan currency to more than eight-year lows, ANZ economists said.