“We strongly urge the United States to immediately mend its ways and end illegal provocations in the name of so-called freedom of navigation,” Senior Col. Wu Qian, a spokesman for the Chinese Ministry of Defense, said Friday on its website. “The American military provocation will only induce the Chinese military to further build up various defensive capacities.”

The loud, swift denunciations by the Chinese government stood in contrast to its muted public response to tensions over North Korea. Pyongyang vowed this week to fire missiles near Guam, an American territory, after President Trump warned of unprecedented “fire and fury” if it threatened the United States.

Mr. Trump has pushed China to use its influence to compel North Korea to stop its missile tests and nuclear weapons development. On Thursday, he suggested that he might spare China trade penalties if it did more to curtail North Korea. “If China helps us, I feel a lot differently toward trade,” he said.

The Chinese Foreign Ministry has not commented about the escalating crisis on its website, and its regular news briefings are in summer recess. Chinese leaders have also not commented publicly.

But Beijing’s reaction to the latest American naval operation has underscored that China has its own geopolitical sore points with the White House, including weapons sales to Taiwan and the repeated freedom of navigation operations in the South China Sea.