BEIJING/SEOUL (Reuters) - North Korea’s 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 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.

U.S. President Donald Trump wrote on Twitter he had received a message from Xi on Tuesday night that his meeting with Kim “went very well” and that Kim looked forward to meeting the U.S. president.

“Look forward to our meeting!” Trump wrote, while adding: “In the meantime, and unfortunately, maximum sanctions and pressure must be maintained at all cost!”

White House spokeswoman Sarah Sanders said the China-North Korea talks and Kim’s decision to travel outside his country were a “positive sign” the U.S.-led pressure campaign to force North Korea to abandon its nuclear weapons has been working. “We’re going to be cautiously optimistic,” she told reporters.

“For years and through many administrations, everyone said that peace and the denuclearization of the Korean Peninsula was not even a small possibility,” Trump tweeted on Wednesday. “Now there is a good chance that Kim Jong Un will do what is right for his people and for humanity.”

Earlier this month, Trump, who has exchanged bellicose threats with Kim in the past year, surprised the world by agreeing to meet the North Korean leader to discuss the crisis over Pyongyang’s development of nuclear weapons capable of hitting the United States.

North Korea’s official media has made no mention of Kim’s pledge to denuclearize or the anticipated meeting with Trump, which is planned for some time in May.

China has traditionally been secretive North Korea’s closest ally but ties have been frayed by Kim’s nuclear weapons programme and Beijing’s backing of tough U.N. 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 tensions 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 Korea was willing to talk with the United States and hold a summit between the countries, it quoted him as saying.

“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 realisation of peace,” Kim said.

‘NUCLEAR UMBRELLA’

Kim Jong Un’s predecessors, grandfather Kim Il Sung and father Kim Jong Il, both promised not to pursue nuclear weapons but secretly maintained programmes to develop them, culminating in the North’s first nuclear test in 2006 under Kim Jong Il.

North Korea has said in previous, failed talks aimed at dismantling its nuclear programme 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.

Slideshow ( 19 images )

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

“Kim Jong Un has finally echoed the unconvincing line of his father that denuclearization is the ‘will’ of Kim Il Sung,” said Daniel Russel, who served as the top U.S. diplomat for Asia until last April.

“While that’s better than his outright rejection of denuclearization to date, it’s not very persuasive in light of his actions and his caveats about the need for the U.S. to first create the right ‘atmosphere’,” Russel said in an email.

Widely read Chinese state-run newspaper the Global Times said the Kim-Xi meeting proved naysayers wrong about Beijing-Pyongyang relations.

Slideshow ( 19 images )

“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 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.

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.

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

North Korea’s official news agency said Kim told a banquet hosted by Xi that his 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”.

It said Xi had accepted an invitation “with pleasure” to visit North Korea.

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