BEIJING — China accused the United States of flouting its sovereignty Tuesday after an American warship sailed near islands claimed by Beijing in the disputed South China Sea, further rattling relations between the countries after weeks of escalating military tension.

A Chinese destroyer came within yards of the U.S. Navy ship Sunday, compelling it to switch direction in what American officials called an “unsafe and unprofessional” clash.

China’s Defense Ministry countered that the USS Decatur should never have traveled through those waters in its “freedom of navigation” mission, provoking Beijing to order a Luyang-class warship to force it away from the Spratly Islands.

“The Chinese vessel took quick action and made checks against the U.S. vessel in accordance with the law, and warned it to leave the waters,” spokesman Wu Qian said in a statement. 

China is rapidly modernizing its forces in an attempt to match the U.S. might in Asia. (Jason Aldag/The Washington Post)

The presence of American ships near the Chinese-claimed archipelago off the coast of the Philippines, Malaysia and southern Vietnam is “seriously threatening China’s sovereignty and security” and “seriously undermining the relations between the two countries and the two militaries,” Wu added.

A statement Monday from the U.S. Pacific Fleet blasted the Chinese response as “aggressive.”

“The PRC destroyer approached within 45 yards of Decatur’s bow, after which Decatur maneuvered to prevent a collision,” spokesman Charlie Brown said.

The Decatur had been conducting what the U.S. military calls freedom of navigation operations, or missions to promote international lawfulness in oceanic territory claimed by multiple countries. 

Washington has said the aim is to reject what it considers excessive maritime claims by any country. 

The Decatur ventured Sunday morning by reefs and rocks that Beijing has tried to turn into artificial islands to expand its grip on the South China Sea. U.S. officials have maintained that such land doesn’t count as real territory, said Lawrence Brennan, a law professor at Fordham University in New York.

American and Chinese warships have had close encounters in the past, he added, but Sunday’s encounter “appears to have been closer than any recent event.”

The maritime showdown came about a week after Chinese officials canceled military talks with the United States that were supposed to be held in Beijing. 

The Chinese government scrapped the discussions in response to U.S. sanctions imposed last month on Chinese military personnel for purchasing Russian combat aircraft and missile supplies.

Then Beijing called off a security meeting with Defense Secretary Jim Mattis scheduled for October, the New York Times reported.

The White House and the State Department did not immediately respond to requests for comment. 

The military strain between the world’s two largest economies has deepened even as they are locked in an increasingly heated trade war.

Washington and Beijing hit each other with the largest round of tariffs yet last week, now covering about half of their goods traded. 

President Trump ordered new levies on $200 billion in Chinese imports, and Beijing responded with tariffs on $60 billion in American products, nearing the point of running out of U.S. goods to target.

Neither side has showed signs of giving up, and no trade negotiations have been scheduled to try to end the battle.

Trump warned in September that if Chinese President Xi Jinping refuses to budge, he will unleash tariffs on an additional $267 billion in Chinese imports, placing higher border taxes on basically everything the United States buys from China.

That order last year amounted to $505 billion.