MANILA, Philippines -- The U.S. military commander in the Pacific warned Friday that the risk of a miscalculation that could trigger a wider conflict in a tense territorial standoff between China and Vietnam is high and urged both nations to exercise restraint.

Adm. Samuel Locklear also urged Southeast Asian nations and China to hasten the drafting of a legally binding "code of conduct" to prevent territorial rifts from turning into armed conflicts that could threaten the region's bustling economies.

Southeast Asian diplomats have accused China of delaying the start of negotiations for such a nonaggression pact while it tries to consolidate its control of disputed territories.

Locklear said he was concerned about a three-week standoff between China and Vietnam near the disputed Paracel Islands and urged them to resolve the territorial conflicts on the basis of international law.

"I have serious concerns," Locklear told reporters. "The risk of miscalculation, I think, is high and we encourage them both to exercise restraint."

China raised the stakes earlier this month when it deployed an oil rig off in waters also claimed by Vietnam, which sent ships to try to disrupt the drilling operation. Street protests morphed into bloody anti-Chinese riots that damaged hundreds of factories.

Vietnamese Prime Minister Nguyen Tan Dung, who also attended an economic forum in Manila, told The Associated Press in written comments Thursday that "like all countries, Vietnam is considering various defense options, including legal actions in accordance with the international law." But he said Vietnam would defend itself if it comes under attack.

Analysts have said that countries confronted by China in disputed waters, like Vietnam, may seek a deeper security alliance with Washington.

When asked by reporters about that possibility, Locklear said Washington has been forging such relationships and would welcome strategic ties with Hanoi.

"We look forward to exploring opportunities to expand our partnership with the nations such as Vietnam as well, but Vietnam is among many," Locklear said.

Speaking to reporters on the sidelines of the World Economic Forum on East Asia, he said that the Asia-Pacific has become the most militarized region in the world, with some of the largest army and naval forces.

"How these forces are managed to create a fabric of security that allows economic success here has not yet been determined," Locklear said. Philippine Foreign Undersecretary Laura del Rosario said the drafting of a code of conduct has been so delayed that it could be overrun by developments in the South China Sea, where territorial spats have flared and become more complicated in recent years.

"We're not acting fast enough and there are so many changes happening now," she said.

China claims nearly all of the South China Sea, bringing it into conflict with the far smaller nations of Vietnam, the Philippines and three others that have rival claims. Beijing also has a territorial dispute with Japan over a cluster of islands in the East China Sea.

Last year, the Philippines filed a complaint against Beijing before an international tribunal in The Hague challenging the legality of its claims. Beijing wants one-on-one talks with each of its rival claimants, something that gives it an advantage due to its sheer size and power.

U.S. efforts to pivot back to Asia after years of heavy military engagement in the Middle East were not meant to curb China's influence, Locklear said, suggesting Asian governments would treat China by its actions in the region.

"In my opinion, the only person that can contain China, is China," Locklear said.

Associated Press writer Oliver Teves contributed to this report.