In remarks that could infuriate China, Duterte hit back at domestic critics who said he has gone soft on Beijing by refusing to push it to comply with an award last year by the Permanent Court of Arbitration in The Hague, which ruled largely in favor of the Philippines.
Duterte said he discussed it with Xi when the two met in Beijing on Monday, and got a firm, but friendly warning.
"We intend to drill oil there, if it's yours, well, that's your view, but my view is, I can drill the oil, if there is some inside the bowels of the earth because it is ours," Duterte said in a speech, recalling his conversation with Xi.
"His response to me, 'we're friends, we don't want to quarrel with you, we want to maintain the presence of warm relationship, but if you force the issue, we'll go to war."
Duterte has long expressed his admiration for Xi and said he would raise the arbitration ruling with him eventually, but needed first to strengthen relations between the two countries, which the Philippines is hoping will yield billions of dollars in Chinese loans and infrastructure investments.
The Hague award clarifies Philippine sovereign rights in its 200-mile Exclusive Economic Zone to access offshore oil and gas fields, including the Reed Bank, 85 nautical miles off its coast.
It also invalidated China's nine-dash line claim on its maps denoting sovereignty over most of the South China Sea.