SINGAPORE — Defense Secretary Jim Mattis sought Saturday to reassure jittery allies in the Pacific about President Trump’s nationalist agenda after delivering a speech that cast North Korea as an “urgent military threat” and cited China for its military actions in the South China Sea.

Mattis, speaking here at the Shangri-La Dialogue defense summit, said that the Trump administration is encouraged by China’s “renewed commitment” to pressure North Korea to stop its nuclear weapons program but that the United States will not accept China’s military buildup in the South China Sea.

“While competition between the U.S. and China, the world’s two largest economies, is bound to occur, conflict is not inevitable,” Mattis said. “Our two countries can and do cooperate for mutual benefit. We will work closely with China where we share common cause.”

The comments came after weeks of the Trump administration seeking to stop North Korea from carrying out tests of ballistic missiles and nuclear weapons. But the appearance also marked the defense secretary’s first public remarks since Trump withdrew Thursday from the Paris climate agreement, the latest of several decisions that have raised concerns among allies about whether the United States is withdrawing from the international stage.

Mattis did not mention the Paris agreement in his speech but was asked afterward by a delegate about Trump’s resistance to several global alliances. The delegate, Michael Fullilove of the Lowy Institute in Australia, cited Trump withdrawing from both the Paris agreement and the 12-nation trade deal known as the Trans-Pacific Partnership and repeatedly criticizing the North Atlantic Treaty Organization.

Mattis responded by saying that, “obviously, we have a new president in Washington, D.C.,” and that “there will be fresh approaches taken.”

But he added that the United States will remain an international leader and that Americans accept that, “like it or not, we are part of the world.” That carries through, he added, despite deep frustration among some of them that their nation has been asked to shoulder at times an “inordinate burden” on the world stage, he said.

Mattis cited American isolationism in the 20th century before World War II and the lessons learned then. America was happy at one time “between our two oceans,” but realized after the war “what a crummy world if we all retreat inside our own borders,” he said.

Then he paraphrased an old quote often attributed to former British Prime Minister Winston Churchill.

“To quote a British observer of us from some years ago: Bear with us. Once we have exhausted all possible alternatives, the Americans will do the right thing,” Mattis said, drawing some laughter. “So, we will still be there. And we will be with you.”

Mattis cited Trump’s trip to Brussels last month to meet with NATO leaders and the defense secretary himself going to Japan and South Korea within days of taking office as examples of how the United States is still involved on a world stage.

“We’re there, and I can give you absolute optimism on this issue,” Mattis said.

Mattis has sought to keep a low profile on his trip, declining to do customary interviews with reporters traveling with him on his plane. He has often advocated positions at odds with Trump’s more nationalistic tendencies, calling for the United States to remain an active part of NATO, fulfill promises that it already has made to international partners and prepare its military for how climate change could lead to new missions.

In his speech, Mattis acknowledged the difficult diplomacy involved in getting China to act against North Korea, a longtime trade partner that shares a border.

While Trump has said that he is confident that Chinese President Xi Jinping will “try very hard” pressure Pyongyang, a Chinese trade partner, Mattis made it sound less certain that will happen.

“Ultimately, we believe China will come to recognize North Korea as a strategic liability, not an asset,” Mattis said.

North Korea, Mattis said, is the major threat in the region and is at odds with the international community. China, on the other hand, is a growing power that has benefited from 70 years of peace in the Pacific but disregarded the concerns of some other Pacific nations, the secretary said.

Mattis said China’s construction of bases and man-made islands in the South China Sea is problematic due to the “nature of its militarization, China’s blatant disregard for international law and its contempt for other nations’ interest its effort to dismiss non-adversarial resolution of issues.”

The defense secretary added: “We oppose countries militarizing artificial islands and enforcing excessive maritime claims unsupported by international law. We cannot and will not accept unilateral, coercive changes to the status quo.”

But Mattis said that there is much more in common between the United States and China than the threat North Korea poses and that he does not consider it a “binary” issue in which the United States can get help from China on North Korea only if Washington “walks away from its values” in making sure international waters remain open to all.

“The problem is North Korea, and if we want to stop the bringing of more military capability into the northwest Pacific, then we have to address the problem that is the threat to Japan, to South Korea and all the other nations,” Mattis said.

Related on Checkpoint:

With eyes on North Korea, the U.S. successfully destroys a mock ICBM over the Pacific

To counter North Korea, admiral says the U.S. should consider adding ballistic missile interceptors in Hawaii

U.S. military deploys advanced missile system to South Korea, citing North Korea threat