The Chinese Foreign Ministry replied to a warning from Philippine President Rodrigo Duterte this week by reminding Manila that Beijing is comfortable taking “necessary steps” against ships it believes are sailing near Chinese territory in the South China Sea, the ministry said on Thursday.

China claims nearly the entire South China Sea; the Foreign Ministry’s warning essentially threatens action against Philippine vessels in any part of the sea, including sovereign Philippine territory.

Duterte remarked in a speech this week that he hoped China would “temper its behavior” in the South China Sea and avoid further antagonizing its neighbors.

The Foreign Ministry responded to Duterte in a statement sent to Reuters, in which it asserted that the Spratly Islands, which legally belong to the Philippines and Vietnam, “were China’s inherent territory.” China also claims territory in the sea that belongs to Malaysia, Brunei, and Taiwan.

“China has a right to take necessary steps to respond to foreign aircraft and ships that deliberately get close to or make incursions into the air and waters near China’s relevant islands, and provocative actions that threaten the security of Chinese personnel stationed there,” the Foreign Ministry asserted. “China urges the relevant party to meet China halfway, and jointly protect the present good situation that has not come easily in the South China Sea.”

China has long laid claim to the region using a map known as the “nine-dash line,” which establishes China’s borders as existing far beyond its legal limits.

In 2016, the Permanent Court of Arbitration at the Hague ruled that China’s claims were illegal after Duterte’s predecessor, former President Benigno Aquino, took China to court over artificial islands it developed on reefs in the Spratly Islands. China vowed to ignore the ruling and has continued developing military assets in the region.

China has since tried to gain favor with the Duterte administration by offering the Philippines small boats and ammunition, which Beijing claims the Philippines can use to protect its part of the South China Sea from drug traffickers. Duterte has made defeating drug crime the top promise of his administration.

Duterte complained about China’s growing presence near the Spratly Islands in a speech at Manila’s Malacanang Palace on Tuesday. “You cannot create an island. It’s man-made … and you say that the air above this artificial island is yours. That is wrong,” he asserted.

“I hope that China will temper its, at least its behavior. I do not want to quarrel with China,” Duterte concluded. “One of these days a hothead commander there will just press a trigger.”

Duterte notably made the remarks in front of the U.S. ambassador to the Philippines Sung Kim. The United States has repeatedly demanded that China end its militarization of the region and helped its allies threatened by it using Freedom of Navigation Exercises (FONOPs), in which U.S. Navy ships navigate through international waters to assert their free nature.

Duterte’s remarks followed the publication of a report revealing that the Chinese military had increased its expulsion of Philippine aircraft from Philippine airspace. Several reports have revealed that the People’s Liberation Army (PLA) similarly attempts to assert itself on American ships and aircraft in the area.

Following his remarks, Philippine Foreign Affairs Secretary Alan Peter Cayetano attempted to argue that Duterte was engaging in constructive criticism, not confrontation, with China.

“I interpret it as even a closer relationship because the closer you are, the more you can tell each other your feelings,” Cayetano told reporters. “In the same manner, if there are things that offend feelings of our Chinese counterparts, whether it’s in the Ministry of Foreign Affairs, in the Communist Party, PLA, and they can speak openly, and we will react.”

Duterte has spoken favorably of China for most of his tenure, even angering some of the Philippines by joking about the South China Sea territorial issue. “If you want, just make us a province, like Fujian,” Duterte joked in February. “Province of Philippines, Republic of China.”

In July, protesters put up banners reading, “Welcome to the Philippines, Province of China,” throughout Manila to protest Duterte’s perceived indifference towards the territorial threat.

A national poll published that month found that nearly three in four Philippine citizens wished to see their government more vocally assert its claims to sovereignty in the South China Sea, an attitude somewhat at odds with Duterte’s prior complacency with China. Since the poll was published, Duterte has more openly challenged China to stay out of Philippine territory.

“Our improved relationship with China does not mean we will waver to defend our interest in the West Philippine Sea,” Duterte said last month.

Follow Frances Martel on Facebook and Twitter.