North Korean leader Kim Jong-un said during his visit to China that he wanted to “meet President Xi Jinping often”, as the traditional allies pledged to reset their relationship after years of setbacks.

The two sides vowed to hold “frequent high-level exchanges” and strengthen communications at all levels, China’s foreign ministry said in a statement.

The visit was Kim’s first outside North Korea since he came to power in 2011. Ties between Beijing and Pyongyang have been stormy in recent years.

According to a report by the Korean Central News Agency, Kim said he and Xi should meet more frequently to consolidate the two nations’ relationship, and that he had extended an invitation to Xi to visit North Korea.

Stressing their shared past, Xi said a strong relationship between the two countries was “a strategic choice and the only right choice for the sides to make based on history and reality”.

“This should not and will not change because of any single event at a particular time,” Xi said, without referring to any specific incidents.

Relations between China and North Korea had been on a downward trend before the leaders’ meeting, with Pyongyang conducting a nuclear test during an important event in China last year and a lack of high-level exchanges.

Xi said Kim’s visit came at a “critical moment” and was “very significant” to the development of relations between the two nations.

Although the foreign ministry described Kim’s visit as informal, he was afforded all of the honours bestowed on state leaders, including a formal welcoming ceremony, a review of troops at the Great Hall of the People and a banquet after the leaders’ talks.

North Korean state television broadcast a 30-minute programme about Kim’s visit in a sign of how highly Pyongyang regards the country’s relationship with China.

Analysts said the meeting of the two leaders also provided clear evidence of the nations’ alliance ahead of Kim’s planned summit with US President Donald Trump.

In a tweet on Wednesday, Trump said he had received a message from Xi that the meeting with Kim had gone well and that Kim was looking forward to meeting him. Trump added, however, that it was essential to maintain both sanctions and political pressure on Pyongyang.

Boo Seung-chan, a research fellow at Yonsei Institute of North Korean Studies in Seoul, said Kim might have been seeking reassurance from China ahead of his talks with Trump, at which he is expected to raise the issue of US troops in South Korea.

“Kim knows that the US and South Korea would never agree to the withdrawal of US troops, so he may take the dovish line of changing the nature of US troops, so they no longer target the North,” he said. “He wants his ally, China, to be part of the assurance deal so as to ensure his regime’s survival.”

In the years since Kim succeeded his father, Kim Jong-il, the relationship between China and North Korea has deteriorated. Pyongyang’s repeated missile launches and nuclear tests, as well as Beijing’s endorsement of United Nations Security Council resolutions against the regime, including a ban on North Korean exports, have done little to help the situation.

One of Pyongyang’s nuclear tests was conducted on September 3 last year as China was hosting an emerging markets summit – a move critics said embarrassed Beijing.

North Korea has also repeatedly criticised China for siding with the United States, and warned Beijing to stop the “dangerous move of collapsing the pillar of North Korea-China relations”.

Although Xi has never visited North Korea, when Song Tao, the head of the Communist Party’s International Liaison Department travelled to Pyongyang in November, Kim did not meet him.

The statements released by the two nations on Wednesday made no mention of their disputes, but did declare their mutual commitment to the denuclearisation of the Korean peninsula.

As well as proposing more frequent high-level visits, Xi suggested the two sides enhance communications on key strategic issues, promote regional peace and strengthen exchanges between ordinary people.

Zhang Baohui, a security analyst at Lingnan University in Hong Kong, said Kim’s trip was a significant move by both sides to repair damaged ties.

For China, having an ally on the Korean peninsula provided an essential counterbalance to the United States’ relationship with South Korea, he said.

Nick Bisley, an international relations professor at La Trobe University in Australia, said the trip was a sign that the gap between North Korea and China had closed.

“North Korea and China are back – it’s like the old days, that whole lips and teeth image,” he said, referring to a quote by the late Chinese leader Mao Zedong.

“Whether it’s true or not, “the messaging is pretty clear,” he said.

Tong Zhao, a fellow at Carnegie Endowment for International Peace, a Washington-based think tank, said it was also important for North Korea to maintain its relationship with China ahead of Kim’s talks with Trump.

“If North Korea has a strong relationship with China, it will be hard for the US to consider military action against North Korea or increase its economic sanctions without China’s support,” he said.