North Korea leader Kim Jong Un has visited Beijing and met China’s President Xi Jinping in his first known trip to a foreign country since he took power in 2011.

The leaders sought to portray strong ties between the long-time allies despite a recent chill as both countries confirmed Mr Kim’s secret trip this week.

The visit highlights Beijing and Pyongyang’s efforts to better position themselves by showing they support each other ahead of Mr Kim’s planned meetings with South Korean President Moon Jae-in and US President Donald Trump in the coming weeks.

Mr Kim made the unofficial visit to China from Sunday to Wednesday at Mr Xi’s invitation, China’s official Xinhua News Agency said.

Mr Xi held talks with Mr Kim at the Great Hall of the People in Beijing and he and his wife Peng Liyuan hosted a banquet for Mr Kim and his wife Ri Sol Ju, Xinhua said. They also watched an art performance together, the news agency added.

Official reports from both countries depicted warm ties between the two leaders in an effort to downplay recent tensions in relations over Mr Kim’s development of nuclear weapons and long-range missiles.

In these reports, “Kim reaffirms the traditional friendship between the two countries as if nothing had ever happened, when the relationship had plummeted to unprecedented lows”, said Bonnie Glaser, an Asia expert at the Centre for Strategic and International Studies.

Ties in recent months have frayed as China supported tougher UN sanctions on North Korea and suspended imports of coal, iron ore, seafood and textiles.

Pyongyang last year seemingly sought to humiliate Beijing by timing some of its missile tests for major global summits in China, while its state media accused Chinese state-controlled media of “going under the armpit of the US” by criticising the North.

People watch a TV report about the meeting between Kim Jong Un and Xi Jinping (Lee Jin-man/AP)
People watch a TV report about the meeting between Kim Jong Un and Xi Jinping (Lee Jin-man/AP)

Mr Xi hailed Mr Kim’s visit as embodying the importance with which the North Korean leader regarded ties with China.

“We speak highly of this visit,” Mr Xi told Mr Kim, according to Xinhua.

For China, the visit also reminds other countries that Beijing remains one of North Korea’s most important allies and is a player not to be sidelined in denuclearisation talks.

It also projects to the Chinese public that Mr Xi is firmly in charge of steering Beijing’s relations with North Korea in a way that favours China’s interests.

“Here is Xi Jinping saying, ‘Don’t worry, everything is going to be great’,” Ms Glaser said.

Mr Trump tweeted on Wednesday that he had received a message from Mr Xi saying that his meeting with Mr Kim “went very well” and that Kim “looks forward to his meeting with me”.

“For years and through many administrations, everyone said that peace and the denuclearisation of the Korean Peninsula was not even a small possibility,” he tweeted.

“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!”

Analysts say Mr Kim would have felt a need to consult with his country’s traditional ally ahead of summits with Mr Moon and Mr Trump. China would also not want Mr Kim’s first foreign meeting to be with someone other than Mr Xi.

Kim Jong Un and Xi Jinping walk together in Beijing (CCTV via AP Video)
Kim Jong Un and Xi Jinping walk together in Beijing (CCTV via AP Video)

“China was getting concerned it could be left out of any initial political agreements that Moon and Kim or Trump and Kim could come to,” said Michael Kovrig, senior adviser for north-east Asia at the International Crisis Group.

“This is China asserting its regional hegemony and influence, saying: ‘Hey, you talk to me first’.”

Mr Kim was described by Xinhua as saying that his country wants to transform ties with South Korea into “a relationship of reconciliation and cooperation”.

The two Koreas are still technically at war because their 1950-53 war ended in an armistice, not a peace treaty.

Mr Kim also said that North Korea is willing to hold a summit with the United States, according to Xinhua.

North Korea’s official Korean Central News Agency published Mr Kim’s personal letter to Mr Xi dated on Wednesday, where he expressed gratitude to the Chinese leadership for showing what he described as “heartwarming hospitality” during his “productive” visit.

Mr Kim said that the first meeting between the leaders of the two countries will provide a “groundbreaking milestone” in developing mutual relations to “meet the demands of the new era”.

Mr Kim also said that he is satisfied that the leaders confirmed their “unified opinions” on mutual issues.

“For the North Koreans, it is in their best interests to enter any meetings with Moon or Trump having shored up and repaired to a certain extent their relations with Beijing,” said Paul Haenle, director of the Carnegie-Tsinghua Centre for Global Policy in Beijing.

KCNA said Mr Kim also called for more meetings with Mr Xi and other Chinese officials to deepen the ties between the countries and also asked Mr Xi to visit North Korea at a time convenient for him, which Mr Xi “gladly accepted”.

The North’s diplomatic move this year follows a tense 2017 when it conducted its most powerful nuclear test to date and tested three intercontinental ballistic missiles designed to target the US mainland.

The developments are being interpreted as the North being desperate to break out of isolation and improve its economy after being squeezed by heavy sanctions.

“At least one of the things that Kim would want out of these meetings is a way forward to begin to ease those sanctions and support from China in that effort,” Ms Glaser said.

China remains North Korea’s only major ally and chief provider of energy, aid and trade that keep the country’s broken economy afloat.

In a speech at a banquet in China, Mr Kim described the traditional allies as inseparable “neighbouring brothers” with a relationship moulded by a “sacred mutual fight” to achieve socialist ideals, according to KCNA.

In addition to the trip being his first abroad as leader, his talk with Mr Xi was his first meeting with a foreign head of state. Mr Kim’s father, late North Korean leader Kim Jong Il, had visited China several times during his rule, lastly in May 2011, months before his death that December.

“It’s most proper that my first overseas trip would be the capital of the People’s Republic of China,” said Mr Kim, according to the North Korean agency. “It’s also one of my noble duties to value the North Korea-China friendship as I do my own life.”