MANILA (Reuters) - The Philippines is prepared to go to war if military personnel are harmed in disputed waters, a top security official said on Wednesday, firing back at criticism the government was going soft on China and allowing it to militarize the South China Sea.

President Rodrigo Duterte has taken flak in recent weeks for not confronting Beijing following news that China had installed missile systems on artificial islands in the busy waterway, including areas within Manila’s Exclusive Economic Zone.

Political opponents are outraged at his government’s failure even to lodge a diplomatic protest, but Duterte, unlike his predecessor, enjoys good relations with Beijing and wants its investment, often saying he cannot afford to go to war with a far superior China.

National Security Adviser Hermogenes Esperon said the Philippines would always try to pursue talks to defuse tension, but war could not be ruled out as a last resort if its military was provoked or aggrieved.

“The other night, the president said if his troops are harmed, that could be his red line,” Esperon told reporters.

The remarks echoed Monday’s comments by Foreign Secretary Alan Peter Cayetano to foreign service members that Duterte had told China he would not allow any unsanctioned construction in the Scarborough Shoal or resource extraction in areas where the Philippines had sovereign rights.

China claims most of the South China Sea, through which about $3-trillion worth of goods passes every year. It has made substantial progress in fortifying its manmade islands in the past few years, which it says it has the right to defend.

Last week, the Philippines expressed “serious concern” over the presence of China’s strategic bombers in the disputed waters, but its response to the installation of missile systems was muted.