Kim Jong gave Xi Jinping a lavish welcome, inviting him to the "Mass Games".

US President Donald Trump once said there was "love" between him and North Korean leader Kim Jong Un, but Xi Jinping is intruding into the relationship to remind them that China is an indispensable chaperone in their nuclear dance.

With his first trip to Pyongyang as president, Xi took another big step to patching up his tattered relations with Kim, whose nuclear tests prompted Beijing to join UN sanctions against its longtime ally.

Xi's two-day visit, which ended Friday, will also serve the Chinese leader in his complicated relationship with Trump, as they prepare to hold talks on their trade war at the G20 summit in Japan next week.

Months after Trump declared that he and Kim had fallen "in love", their nuclear talks faltered as their second summit in Vietnam in February ended without an agreement.

Trump has also repeatedly called Xi his "friend", but their own negotiations to end the US-China tariffs war broke down last month.

With Trump's relationship with Kim on the rocks, Xi has found an opening.

After the North Korean leader travelled to China four times in the past year, Xi has finally reciprocated, declaring in North Korea's official newspaper that the friendship between their nations was "irreplaceable".

Kim gave Xi a lavish welcome, inviting him to the "Mass Games", an epic music and dance show in a packed stadium that featured the song "I love you China" and a giant portrait of Xi.

"(Xi) wants to use his visit to Pyongyang to demonstrate to President Trump that China's role on the Korean Peninsula is indispensable," said Bonnie Glaser, senior adviser for Asia at the Center for Strategic and International Studies in Washington.

"And if Xi can persuade Kim to resume talks with the US, he hopes that Trump will ease up pressure on trade," Glaser told AFP.

Glaser noted that Trump himself made the link between a trade deal and China helping with North Korea.

But Trump has also seen Xi as a potentially negative influence on Kim, calling him a "world-class poker player" last year, as he noted a change of attitude by the North Korean leader after meeting the Chinese president.

Leverage

In talks on Thursday, Xi told Kim that he was "willing to strengthen coordination and cooperation" with North Korea and other parties, and play a "positive and constructive role" in achieving denuclearisation of the Korean Peninsula, according to Chinese state media.

North Korean leader Kim Jong Un meets with China's President Xi Jinping during Xi's visit in Pyongyang

Ahn Chan-il, a North Korean defector and researcher in Seoul, said Xi is using North Korea as leverage in his own confrontation with the United States.

"Xi and North Korea... are saying the Beijing-Pyongyang alliance forged in blood will not be affected by Trump, regardless of any economic incentives to effect a change," he said.

China, which fought alongside the North in the Korean War, remains Pyongyang's main diplomatic and economic backer despite tensions over the nuclear issue.

Lu Chao, a North Korean expert at China's Liaoning academy of social sciences, said Beijing "will certainly play a major role in mediating the return of the DPRK and the United States to the negotiating table."

But Lu said it was wrong to think that China would use North Korea as a bargaining chip -- a notion that the Chinese foreign ministry has also rejected.

No Midas Touch

Shi Yinhong, professor of international relations at Renmin University in Beijing, said ties between China and North Korea have not been "fully repaired" just yet, as China still enforces UN sanctions.

"With the improvement of Sino-DPRK relations, China can restore some influence on the DPRK, but the main thing is that Kim Jong Un makes his own decisions," Shi said.

In a sign that the neighbours are not always in sync, North Korean media did not carry comments by Kim reported by Chinese state broadcaster CCTV, which quoted him as saying that he was "willing to be patient" in the talks with the US, but wanted "the parties concerned" to meet him halfway.

The state-run China Daily sought to play down Xi's influence on North Korea.

"The world may hope that the Chinese leader has the magic touch that can turn a stone to gold," the newspaper said in an editorial.

"But it is unrealistic to expect that Xi can solve all the peninsula issues with a two-day visit -- even if Beijing has always been the most reliable and considerate partner to Pyongyang."