After a surprise four-day visit North Korean leader Kim Jong-un departed China with President Xi Jinping’s backing for a second summit with US president Donald Trump, state media reported.

Mr Xi hoped the two leaders “meet each other halfway”, the state news agency Xinhua reported, adding that China would play “a positive and constructive role in maintaining peace and stability and realising denuclearisation on the peninsula”.

Mr Trump and Mr Kim first met for a landmark summit in Singapore last June, but efforts to bring about denuclearisation have been tied up in a prolonged stalemate since then, as the two countries debate what measures need to be taken and who should take them first.

Pyongyang wants Washington to lift punishing economic sanctions, imposed over its nuclear programme, and declare an official end to the 1950-53 Korean War.

Xinhua described the atmosphere at the talks in Beijing as “cordial and friendly”. It was Mr Kim’s fourth visit to China in a year and he was accompanied by his wife, Ri Sol-ju.

Kim Jong-un with China’s President Xi Jinping in Beijing. Photograph: KCNA via KNS/AFP/Getty Images Mr Xi also agreed to visit Pyongyang for the first time since Mr Kim came to power, as relations between China and North Korea continue to warm.

Beijing had been angered by the North’s decision to go ahead with its nuclear programme despite China’s opposition to the plan.

However, relations between Pyongyang and Beijing have improved as China seeks to maintain its leverage with the North as it negotiates with South Korea and the US about denuclearisation.

Improved ties between the two Koreas, divided since the end of the Korean War, have been largely brokered by South Korea’s president Moon Jae-in.

At a news conference on Thursday, Mr Moon urged North Korea to be more bold in its approach to denuclearisation.

“I believe North Korea needs to take practical denuclearisation steps more boldly if it wishes to resolve the issue of international sanctions because the issue of international sanctions depends on the speed of North Korea’s denuclearisation process,” Mr Moon said.

Mr Kim’s visit to China indicated a second summit was imminent.

“I believe Chairman Kim’s China visit is a sign that the second North Korea-US summit is not far away. China has continued to play a positive role in the process of inter-Korean dialogue, as well as US-North Korea talks,” he said.

A second summit would also lay the ground for Mr Kim’s first visit to South Korea, which has been delayed by the stalled negotiations.

During his visit, Mr Kim was also taking careful note of China’s economic progress, saying he was “deeply impressed by the achievements made in China’s economic and social development”.