Philippines President Rodrigo Duterte said his Chinese counterpart had threatened him that Beijing would “go to war” if Manila begins drilling for oil in the South China Sea.

The inflammatory comments, mentioned offhand by the firebrand president during a speech Friday, come after the two countries have sought to reset ties after years of contention over conflicting claims in the South China Sea.

Mr. Duterte said he had told Chinese President Xi Jinping that the South China Sea “is ours and we intend to drill oil there. If it’s yours, well, that is your view but my view is I can drill the oil.”

The Philippine leader said Mr. Xi had told him that the two countries are friends. “We do not want to quarrel with you. We want to maintain a warm relationship but if you force the issue we will go to war.”

China’s Foreign Ministry didn’t respond to a request for comment. Chinese officials have in the past shown tolerance for Mr. Duterte’s blunt remarks.