Beijing says it has lodged “stern representations” with Washington after an American navy warship sailed near the disputed islands in the South China Sea, prompting the Chinese military to scramble warplanes and vessels to warn it off.

The Foreign Ministry said in a statement that the US violated China’s law after its guided-missile destroyer, USS McCampbell, sailed within 12 nautical miles of the Xisha Island chain, called Paracel by Beijing’s rivals.

The ministry’s spokesman Lu Kang urged Washington to stop such actions in the strategic waters, mostly claimed by Beijing.

“We urge the United States to immediately cease this kind of provocation,” he said, adding that China had sent military ships and aircraft to identify and warn off the ship.

Earlier, US Navy spokeswoman Rachel McMarr said in an emailed statement that the warship had sailed near the islands “to challenge excessive maritime claims.”

The operation was not about any one country or to make a political statement, she said.

China has constantly warned Washington that close military encounters by air and naval forces of the two countries in the region could easily trigger miscalculation or even accidents at sea or in air.

The US – which sides with China’s rivals in their territorial claims -- says such military operations are meant to protect “freedom of navigation” in the sea, a gateway for trillions of dollars in maritime trade each year.

The waters are also claimed by Vietnam, tge Philippines, Malaysia, Indonesia, Taiwan and Brunei.

Late last week, President Xi Jinping signed an order which calls on China's armed forces to get prepared for a “comprehensive military struggle” amid an era of drastic changes.

He told a meeting of the Central Military Commission in Beijing that various predicable and unpredictable risks and challenges were arising and that the armed forces needed to be able to respond quickly to emergencies and nurture new types of combat forces.

The latest naval friction comes as a delegation of US negotiators is in Beijing for talks over a bitter trade dispute between the two economic powers.

It all started when US President Donald Trump announced in June 2018 that $50 billion worth of Chinese goods would be subject to 25 percent tariffs in an attempt to “fix” the US-Chinese trade deficit. Since then, the two countries have exchanged several rounds of trade tariffs.

The two leaders, however, came to an agreement on a truce for the first time on the sidelines of the G20 summit in Buenos Aires in December 2018. The ceasefire has so far showed some signs of progress, and an absence of new threats from the White House.