The Pentagon’s top general and his Chinese counterpart have signed a new agreement aimed at improving communication in times of crisis, a step that brings Beijing and Washington closer together as the two nations grapple with what to do about North Korea and its efforts to build an intercontinental ballistic missile capable of carrying a nuclear warhead.

Marine Gen. Joseph F. Dunford Jr., the chairman of the Joint Chiefs of Staff, and Gen. Fang Fenghui of the Chinese People’s Liberation Army signed the deal at the Chinese military headquarters in Beijing at the outset of a three-day visit by Dunford. The agreement establishes what the Pentagon called the Joint Staff Dialogue Mechanism, in which a three-star officer on Dunford’s staff, Army Lt. Gen. Richard D. Clarke, will communicate regularly with a Chinese counterpart.

Chinese President Xi Jinping described relations with the United States as strained last month, when Washington asked Beijing to do more to pressure North Korea to stop its nuclear weapons programs. But there have been some signs of improvement in recent days, including China’s decision to ban North Korean iron ore, iron, lead and coal as part of a new United Nations sanctions package against Pyongyang.

China and the United States appear to remain far apart on other issues, including a U.S. plan to deploy a missile-defense system known as Terminal High Altitude Area Defense (THAAD) to South Korea and China’s efforts to expand its territorial claims in the South China Sea. China also warned the Trump administration last month not to start a trade war with Beijing and split up the coalition countering North Korea.

Dunford, speaking in China, acknowledged there are a number of challenges.

“To be honest, we have many difficult issues where we will not necessarily have the same perspectives,” Dunford said according to a Pentagon news account. “But from the meeting we had in Washington, D.C., and the meeting we just had, I know we share one thing: We share a commitment to work through these difficulties. With the guidance from our presidents and the areas of our cooperation, I know we will make progress over the next few days.”

“I think our collective challenge is to sincerely and with candor attack these issues that we have to address,” he said.

Navy Capt. Darryn James, a U.S. military spokesman, said in a statement that Dunford started his meeting Tuesday with Fang by stressing the importance of “candid and professional communication” between their militaries “because both nations have tough issues where we do not share the same perspective.” Dunford stressed that the new agreement will “only be useful if it results in reducing the risk of miscalculation, which not only has long-term benefits to manage bilateral differences but is especially critical now due to growing North Korean provocations,” James said.

Dunford also once again emphasized that North Korea’s ballistic missile and nuclear weapons programs threaten the entire world, including China, Russia, the United States and its allies, James said.

Dunford will spend three days in China, visiting PLA units, including China’s Northern Theater Command in Shenyang, the capital of Liaoning province, which borders North Korea.

The generals signed the agreement after days of bellicose rhetoric between President Trump and North Korea, and as North Korea appeared to ease up on a threat to shoot missiles toward the U.S. island territory of Guam. A state-run North Korean media outlet reported that North Korean leader Kim Jong Un said he would watch the United States “a little more” rather than act quickly, while at the same time warning the United States to avoid “reckless actions” on or near the Korean Peninsula.

Trump sought to take credit for North Korea’s change in tone in tweets Wednesday.

“Kim Jong Un of North Korea made a very wise and well reasoned decision,” he tweeted. “The alternative would have been both catastrophic and unacceptable!”

In Moscow, Russian Foreign Minister Sergei Lavrov said world powers have “nearly exhausted” the economic pressures they can put on North Korea. In an apparent preemptive message to other U.N. Security Council members, Lavrov said Russia does not support further measures to try to squeeze the North Korean economy.

“A resolution of the North Korea nuclear issue by military force is completely unacceptable and the peninsula’s nuclear issue must be peacefully resolved by political and diplomatic methods,” Lavrov was quoted as saying by the Chinese Foreign Ministry following his call with the Chinese foreign minister.

Brian Murphy contributed to this report.