BEIJING — China urged the United States to remain “coolheaded” over North Korea and not to turn its back on dialogue, as visiting Secretary of State Rex Tillerson expressed a “sense of urgency” to curb dangerous levels of tension on the Korean Peninsula.

On his first trip to Asia this past week, Tillerson had declared that diplomacy has failed to persuade North Korea to abandon its nuclear program, and that a new approach was needed. On Friday in Seoul, he warned ominously that all options were on the table to counter the threat from Pyongyang.

President Trump weighed in Friday by goading China over Twitter for not doing enough to help prevent its ally from “behaving very badly.”

But in a joint news conference Saturday with his Chinese counterpart, Tillerson struck a more diplomatic note, choosing to play down differences with Beijing and stress that both countries share the goal of a denuclearized Korean Peninsula.

“We share a common view and a sense that tensions on the peninsula are quite high right now and that things have reached a rather dangerous level, and we’ve committed ourselves to doing everything we can to prevent any type of conflict from breaking out,” Tillerson said.

Chinese Foreign Minister Wang Yi agreed, but also had some advice for his American counterpart.

“No matter what happens, we have to stay committed to diplomatic means as a way to seek peaceful settlement,” he said. “We hope all parties, including our friends from the United States, could size up the situation in a coolheaded and comprehensive fashion, and arrive at a wise decision,” he said.

In February, China suspended coal imports from North Korea for the rest of the year, a move that cuts off the regime’s major financial lifeline. Wang pledged to maintain U.N. sanctions on North Korea but said Security Council resolutions had also included “clear provisions for efforts to resume talks to de-escalate the tension and to safeguard stability on the peninsula.”

North Korea has amassed a sizable nuclear stockpile and appears at the brink of being able to strike the U.S. mainland and American allies in Asia. The situation has emerged as a major, early foreign-policy test for the new Trump administration.

Tillerson said both China and the United States felt “a certain sense of urgency” in trying to persuade Pyongyang to “make a course correction” and abandon its nuclear weapons program.

In Seoul on Friday, Tillerson said the administration was exploring an array of diplomatic, economic and security measures to put more pressure on North Korea, including tighter sanctions, and that while a military response was possible if the threat from Pyongyang’s missile program grew, “we have many, many steps we can take before we get to that point.”

Previous efforts to offer carrot-and-stick diplomacy to North Korea have failed, beginning with a 1994 deal under which Pyongyang would have received aid and two proliferation-resistant nuclear power plants in return for freezing and eventually dismantling its nuclear weapons program.

That deal collapsed in 2002, and North Korea achieved its first atomic test in 2006. The George W. Bush administration’s efforts at a new deal collapsed, and Pyongyang has managed to build up its stockpile of nuclear material as well as refine its missiles despite what on paper look like crushing international sanctions.

But despite the failure of previous talks, and North Korea’s chronic inability to keep previous promises, China insists that dialogue remains the only option.

It has proposed a deal whereby the United States suspends its annual military exercises with South Korea in return for North Korea suspending its nuclear program, but Washington has already rejected the idea, saying it first needs to see “positive action” from Pyongyang.

Wang said tensions had risen precisely because talks had broken down, and he urged all sides to get back to the negotiating table.

Overall, though, Tillerson and Wang tried to strike a positive tone, repeating the reassuring mantra that U.S.-China relations were founded on the principles of avoiding conflict and confrontation, and promoting mutual respect and “win-win cooperation.”