North Korean leader Kim Jong Un told Chinese President Xi Jinping that he was committed to giving up his nuclear weapons if security guarantees were met, during a surprise visit to the Chinese port city of Dalian just weeks ahead of a planned summit between Kim and U.S. President Donald Trump, Chinese state media said late Tuesday.

The talks, held on Monday and Tuesday, came some 40 days after Kim visited Beijing in March to meet Xi on his first trip outside the country since taking over as the North’s leader in 2011.

“As long as relevant parties abolish their hostile policies and remove security threats against the DPRK, there is no need for the DPRK to be a nuclear state and denuclearization can be realized,” Kim was quoted by China’s official Xinhua News Agency as saying, using the acronym for the North’s official name, the Democratic People’s Republic of Korea.

The relevant parties was a clear reference to the United States and its allies that have backed the U.S.-led “maximum pressure” campaign to rein in the North’s nuclear weapons program. Japan has been one of the biggest backers of this campaign.

“I hope to build mutual trust with the U.S. through dialogue,” Kim said. A political resolution of tensions on the peninsula and denuclearization should proceed with the “relevant sides” taking “phased and synchronous measures in a responsible manner,” he added.

Xi said “China supports the DPRK’s adherence to the denuclearization of the peninsula, and supports the DPRK and the U.S. in negotiating and resolving the peninsula issue through dialogue.”

The White House has demanded that North Korea immediately commit to denuclearization, a position that appeared to grow stronger in recent days when newly minted Secretary of State Mike Pompeo said on May 2 that Washington is committed to the “permanent, verifiable, irreversible dismantling of North Korea’s weapons of mass destruction program.”

That terminology went beyond previous U.S. statements demanding the “complete verifiable, irreversible dismantling of its nuclear weapons program.” It was unclear what this discrepancy meant.

China is the North’s sole ally and benefactor, but ties had soured for years under Kim until his March visit appeared to put them back on track.

“After the first meeting between me and Comrade Chairman, both China-DPRK relations and the Korean Peninsula situation have made positive progress. I feel happy about it,” Xi was quoted as saying.

The Chinese leader also said he was willing to meet Kim again “to make joint efforts to push the healthy and stable development of China-DPRK relations, realize long-lasting peace and stability on the Korean Peninsula, and promote regional peace, stability and prosperity.”

Kim said that Sino-North Korean ties, as well as the “Korean Peninsula situation” had undergone “meaningful progress since March.”

“These are the positive outcomes of the historic meeting between me and Comrade General Secretary,” he added.

Xinhua said Xi hosted a welcome banquet for Kim on Monday and the two leaders strolled along the coastline at a government guesthouse and had lunch together on Tuesday.

“At a crucial time when the regional situation is developing rapidly, Kim said he came to China again to meet with (Xi) and inform him of the situation,” Xinhua said.

CGTN footage showed Xi wearing a Western suit and Kim in his standard Mao suit. They stood on a beach, sat on an outdoor deck and strolled through lush gardens.

“In a cordial and friendly atmosphere, the top leaders of the two parties and the two countries had an all-round and in-depth exchange of views on China-DPRK relations and major issues of common concern,” Xinhua said.

Chinese state-run media reports did not directly mention the planned Trump meeting or last month’s inter-Korean summit, but both were likely to have topped the agenda of the Kim-Xi talks.

Trump spoke Tuesday with Xi on North Korea and trade, according to the White House, with both agreeing on the importance of continuing to implement sanctions on North Korea until it permanently dismantles its nuclear and missile programs.

Xi urged Trump to take Pyongyang’s “reasonable security concerns” into consideration, according to Chinese state broadcaster CCTV.

Xi told Trump that he supports the planned meeting between the U.S. and North Korean leaders, saying that he “hopes the U.S. and North Korea can work together, build mutual trust” and “consider North Korea’s reasonable security concerns,” the report said.

Media reports had earlier speculated that a high-ranking North Korean official had visited the Chinese city after a private jet belonging to VIPs from the North and an Air Koryo jet had been spotted at the Dalian airport. Footage posted online also showed a convoy of black cars moving through the streets of the city on Monday in a scene reminiscent of Kim’s earlier Beijing visit.

Dalian was a favorite meeting spot for past Chinese and North Korean leaders, including Kim Il Sung and Kim Jong Il.

The meeting with Xi came weeks before Kim’s planned summit with Trump to discuss denuclearization in the first-ever meeting of sitting leaders from the two countries.

Trump said Friday that the two sides had decided on a time and place for their meeting, with media reports saying the summit will take place in Singapore in mid-June.