China has vowed to take “necessary measures” to protect its sovereignty after a US navy destroyer sailed near a disputed shoal claimed by Beijing in the South China Sea this week.

China’s foreign ministry said the missile destroyer USS Hopper came within 12 nautical miles – an internationally recognised territorial limit – of Huangyan Island, which is also known as Scarborough Shoal and subject to a rival claim by the Philippines. Two US officials confirmed it.

The officials, who spoke on condition of anonymity, said the patrol was in line with international law and was an “innocent passage”, in which a warship effectively recognises a territorial sea by crossing it quickly, without stopping.

The US military says it carries out “freedom of navigation” operations throughout the world, including in areas claimed by allies, and that they are separate from political considerations.

The Pentagon did not directly comment on the latest patrol but said such operations were routine.

“All operations are conducted in accordance with international law and demonstrate that the United States will fly, sail and operate wherever international law allows,” Pentagon spokesman Lt Col Christopher Logan said.

Chinese foreign ministry spokesman Lu Kang said the USS Hopper violated China’s sovereignty and security interests, and threatened the safety of Chinese vessels and personnel. Lu said the Chinese navy ordered the vessel to withdraw after determining its identity.

The incident was the latest US naval operation challenging extensive Chinese claims in the South China Sea. The United States has criticised China for constructing islands and military installations in the sea, saying they could be used to restrict free movement in a critical global trade route.

Lu said China “firmly opposes” efforts to use freedom of navigation as an excuse to hurt its sovereignty and urged the United States to “correct its mistakes”.

China’s defence ministry said the repeated dispatch of US warships to the region was “undermining regional peace and stability” and hurting bilateral relations.

Greg Poling, a South China Sea expert at the Center for Strategic and International Studies, said the Pentagon appeared determined to keep up regular freedom of navigation patrols in the sea, with one every six weeks or so, in spite of Chinese objections.

“The last made public was in October, but we should expect that there was at least one other in the interim,” he said. “The only time word is getting out these days is if Beijing makes an issue of it.”