North Korean leader Kim Jong-un pledged his commitment to 'denuclearization' and to meet U.S. officials, China said on Wednesday after his meeting with President Xi Jinping, who promised China would uphold its friendship with its isolated neighbour.

After two days of speculation, China and North Korea both confirmed that Kim had travelled to Beijing and met Xi during what China called an unofficial visit from Sunday to Wednesday.

The visit was Kim's first known trip outside North Korea since he assumed power in 2011, and is believed by analysts to serve as preparation for upcoming summits with South Korea and the United States.

North Korea's KCNA news agency made no mention of Kim's pledge to denuclearize, or his anticipated meeting with U.S. President Donald Trump that is planned for some time in May.

China has traditionally been secretive North Korea's closest ally, but ties have been frayed by its pursuit of nuclear weapons and China's backing of tough UN sanctions in response.

China's Foreign Ministry cited Kim in a lengthy statement as telling Xi the situation on the Korean peninsula was starting to improve because North Korea had taken the initiative to ease tension and put forward proposals for talks.

"It is our consistent stand to be committed to denuclearization on the peninsula, in accordance with the will of late President Kim Il-sung and late General Secretary Kim Jong-il," Kim Jong-un said, according to the ministry.

North Korean leader emerges after mysterious train ride to Beijing 1:51

North Korea was willing to talk with the United States and hold a summit between the two countries, he said.

"The issue of denuclearization of the Korean peninsula can be resolved if South Korea and the United States respond to our efforts with goodwill, create an atmosphere of peace and stability while taking progressive and synchronous measures for the realization of peace," Kim said.

'Nuclear umbrella'

Kim's predecessors, grandfather Kim Il-sung and father Kim Jong-il, both promised not to pursue nuclear weapons but secretly maintained programs to develop them, culminating in the North's first nuclear test in 2006 under Kim Jong-il.

The North had said in previous, failed talks aimed at dismantling its nuclear program it could consider giving up its arsenal if the United States removed its troops from South Korea and withdrew its so-called nuclear umbrella of deterrence from South Korea and Japan.

Kim, Xi and their wives, Ri Sol-ju, left, and Peng Liyuan, right, pose for a photo at Diaoyutai State Guesthouse in Beijing on Tuesday. (Korean Central News Agency/Korea News Service via Associated Press)

Many analysts and former negotiators believe this still constitutes North Korea's stance and remain deeply skeptical Kim is willing to give up the weapons his family has been developing for decades.

At first wrapped in secrecy, the announcement of Kim's visit soon became the third-most discussed topic on China's Weibo microblogging site, although many state media outlets blocked their comments sections.

Widely read Chinese state-run newspaper the Global Times praised the meeting as proving naysayers wrong about Beijing-Pyongyang relations.

"China and North Korea maintaining their friendly relations provides a positive force for the whole region and promotes

strategic stability in northeast Asia," it said in an editorial.

Kim's appearance in Beijing involved almost all the trappings of a state visit, complete with an honour guard and banquet at Beijing's Great Hall of the People.

Kim and Xi pictured at a banquet at the Great Hall of the People in Beijing on Monday. (Korean Central News Agency/Korea News Service via Associated Press)

Kim and Xi also met at the Diaoyutai State Guest House, where Kim Il-sung planted a tree in 1959 that still stands.

State television showed pictures of the two men chatting and Kim's wife, Ri Sol Ju, getting a warm welcome from Xi's wife, Peng Liyuan.

Trump briefed

China briefed Trump on Kim's visit and the communication included a personal message from Xi to Trump, the White House said in a statement.

"We're going to be cautiously optimistic but we feel like things are moving in the right direction and the meeting yesterday was a good indication that the maximum pressure campaign has been working," White House spokesperson Sarah Sanders told reporters on Wednesday.

Trump wrote about the matter earlier in the day.

For years and through many administrations, everyone said that peace and the denuclearization of the Korean Peninsula was not even a small possibility. Now there is a good chance that Kim Jong Un will do what is right for his people and for humanity. Look forward to our meeting! —@realDonaldTrump

Received message last night from XI JINPING of China that his meeting with KIM JONG UN went very well and that KIM looks forward to his meeting with me. In the meantime, and unfortunately, maximum sanctions and pressure must be maintained at all cost! —@realDonaldTrump

Analysts said the meeting strengthened North Korea's position ahead of any meeting with Trump by aligning Beijing and Pyongyang while reassuring China it was not being sidelined in any negotiations.

"It seems that North Korea is not ready to deal with the United States without support and help from its longtime ally China," said Han Suk-hee, professor of Chinese studies at South Korea's Yonsei University.

A top Chinese diplomat, Politburo member Yang Jiechi, will brief officials, including South Korean President Moon Jae-in, in Seoul on Thursday about the Beijing talks, the presidential office in Seoul said.

Kim told a banquet hosted by Xi the visit was intended to "maintain our great friendship and continue and develop our

bilateral ties at a time of rapid developments on the Korean peninsula," according to KCNA.

Xi had accepted an invitation "with pleasure" to visit North Korea, KCNA said.

China made no mention of Xi accepting an invitation, but Foreign Ministry spokesperson Lu Kang pointed to a line in their statement citing Xi as saying he is willing to maintain regular communications with North Korea via visits and exchanges of envoys and messages.

"I have to say that China and North Korea have a tradition of high-level mutual visits," Lu told a daily news briefing.

In this photo provided by KCNA, Kim is seen waving as he is given a sendoff at Beijing station in Beijing on Tuesday. (Korean Central News Agency/Korea News Service via Associated Press)

China had largely sat on the sidelines as North Korea improved relations with South Korea recently, raising worry in Beijing that it was no longer a central player in the North Korean issue, reinforced by Trump's subsequent announcement of his proposed meeting with Kim in May.

"China is North Korea's lifeline, so the notion, from a Chinese perspective, that Kim Jong-un could have had these other two meetings before meeting with Xi Jinping, I think the Chinese just thought that is not going to happen," said Paul Haenle, director of the Carnegie-Tsinghua Center in Beijing and the former White House representative to North Korea denuclearization talks from 2007-2009.