(CNN) A US Navy ship had an "unsafe" interaction with a Chinese warship Sunday while the US vessel was conducting a freedom of navigation operation near the disputed Spratly Islands in the South China Sea, causing the US ship to maneuver "to prevent a collision," according to US defense officials.

"A (People's Republic of China) Luyang destroyer approached USS Decatur in an unsafe and unprofessional maneuver in the vicinity of Gaven Reef in the South China Sea," Capt. Charles Brown, a spokesman for US Pacific Fleet, told CNN in a statement confirming the incident.

Brown said the Chinese warship "conducted a series of increasingly aggressive maneuvers accompanied by warnings for the Decatur to depart the area."

He added that the Chinese destroyer "approached within 45 yards" of the front of the US ship, adding that the Decatur "maneuvered to prevent a collision."

"Our forces will continue to fly, sail and operate anywhere international law allows," he said.

The close encounter would give the ship's captains just seconds to react to any course change, said Carl Schuster, a former US Navy captain who spent 12 years at sea.

"This was very dangerous. Captains get very nervous when ships get closer than 1,000 yards," said Schuster, now a Hawaii Pacific University professor.

Minute rudder and engine speed corrections are needed to keep ships separated and even a slight miscalculation can result in a collision, he said.

This incident comes amid heightened US-China tensions over a broad range of issues. Chinese ships often shadow US vessels during freedom of navigation operations but those interactions are usually considered safe.

CNN reported Sunday the USS Decatur sailed within 12 nautical miles of Gaven and Johnson reefs in the Spratly Islands as part of what the US Navy calls freedom of navigation operations, which are meant to enforce the right of free passage in international waters.

While the US Navy conducts such freedom of navigation operations all over the world, China is particularly sensitive about the operations when they come near areas where the Chinese government has built islands and established military facilities on disputed maritime features.

"The US has been repeatedly sending warships to the islands and the adjacent waters in the South China Sea, which has seriously threatened China's sovereignty and safety," Chinese Defense Ministry spokesman Wu Qian said Tuesday.

"The Chinese military will resolutely perform its defense duties and continue to take all necessary measures to safeguard our sovereignty and the regional peace and stability," Wu said.

Schuster said China seems to be adopting "a more aggressive response policy" to US ships, emboldened in part by last year's collisions between US destroyers and merchant ships in the Asia-Pacific.

Naval academics theorize the collisions that killed 16 US sailors have the Chinese navy doubting US seamanship skills and giving it confidence to "intimidate" US ship captains, Schuster said.

Mattis cancels trip to Beijing

In a sign of the increasing tensions, late last week US Secretary of Defense James Mattis pulled out of a planned visit to Beijing later in October, two US officials told CNN.

Mattis had originally planned to visit the Chinese capital to meet with senior Chinese officials to discuss security issues. The last-minute cancellation of the unannounced trip has not been publicly confirmed by the Pentagon.

Tensions have been growing across multiple fronts, from the Trump administration's tariffs on Chinese goods to new sanctions announced against the Chinese military.

At a news conference last week, President Donald Trump said his often-mentioned friendship with Chinese leader Xi Jinping may have come to an end.

"He may not be a friend of mine anymore. But I think he probably respects me," Trump said.

Speaking at the United Nations Security Council last week Trump said the Chinese government was attempting to interfere in the 2018 midterm elections to tilt them against the Republicans.

"They do not want me or us to win because I am the first president ever to challenge China on trade," Trump said. "We are winning on trade. We are winning at every level. We don't want them to meddle or interfere in our upcoming election."

The Trump administration imposed 10% tariffs on $200 billion in Chinese goods on September 24, in addition to the trade measures already in place. The Chinese government responded in kind, with 5% to 10% tariffs on $60 billion in US goods.

Following the new round of tariffs, Beijing called off planned trade talks with Washington, leaving no end in sight for the trade war.

"How could you negotiate with someone when he puts a knife on your neck?" Chinese deputy trade negotiator Wang Shouwen said at a news conference last Tuesday, saying that resuming the talks would be difficult.

In another sign of the growing tensions, the Chinese government canceled a port visit to Hong Kong by the USS Wasp , a US Navy amphibious assault ship, last week.

It followed closely the decision by the US government to sanction Chinese military figures over their purchases of Russian combat aircraft and missile systems

Correction: This article has been updated to reflect that the "unsafe" interaction took place near the Spratly Islands.