Kim Jong-un declared North Korea's unstinting "friendship, unity and cooperation" with Beijing during his third visit to China this year, in a show of loyalty to his main ally following a landmark summit with United States President Donald Trump.
The two-day visit, which ends Wednesday, is designed to reassure Beijing that Pyongyang will not neglect its interests as Mr Trump and the young autocrat move into uncharted diplomatic terrain.
The performance is part of a delicate balancing act for Mr Kim, who analysts say is seeking to play US and Chinese interests off each other while maintaining good relations with Beijing, his economic patron and diplomatic protector.
China and the US both hope to see the Korean peninsula free of nuclear weapons, but Beijing is concerned Washington and Pyongyang might move closer at its expense, a possibility that China sees as threatening to its economic and security interests in the region.
While China was not present at the June 12 summit in Singapore, it lent Mr Kim a plane to travel to the city-state, a clear sign that it remains an influential force in the diplomatic shuffle.
The Cold War-era allies, which fought side-by-side against US-led UN forces and South Korea in the 1950-1953 Korean War, have sought to repair ties strained by Pyongyang's nuclear tests and Beijing's support of subsequent UN sanctions.
Mr Kim chose Beijing for his first official foreign trip in March and met Mr Xi again in May in the northeastern port city of Dalian.
Mr Kim's agenda for Wednesday was not made public. An AFP journalist saw a motorcade leaving the Diaoyutai guest house for foreign dignitaries in Beijing, but it was unclear where it was headed.
During his meeting with Mr Xi on Tuesday, Mr Kim thanked China for "positive and sincere support and good help for the successful" summit with Mr Trump, according to North Korea's official KCNA news agency.
The North Korean leader, who was greeted by a military honour guard and cheering children at the Great Hall of the People on Tuesday, said he valued the "recently strengthened strategic cooperation" between the two countries.
"He expressed the determination and will to further develop the closer relations of friendship, unity and cooperation between the two parties and the two peoples of the DPRK and China," KCNA said.
Koreas holding military talks to reduce tensions on border
Tokyo concerned over Trump cancellation of war games
North Korea's Kim knows denuclearisation must be 'quick': Pompeo
Mr Kim also invoked the "prospect for the denuclearisation of the Korean Peninsula" following his meeting with Mr Trump.
For his part, Mr Xi told Mr Kim that China "speaks highly" of his summit with Mr Trump and he urged Washington and Pyongyang to implement their agreement struck in Singapore.
The Chinese leader vowed that Beijing would continue to play a "constructive role" in the nuclear diplomacy.
The official media of both countries did not say whether Mr Kim and Mr Xi discussed the prospect of easing UN sanctions that have crippled North Korea's economy, although analysts said it could have been part of the agenda.
Shin Bum-cheol, a senior fellow at the Seoul-based Asan Institute for Policy Studies, said Mr Kim and Mr Xi were likely seeking "common ground" following the Singapore summit.
For China, North Korea can serve as "an important card" as Beijing faces a potential trade war with the United States," Mr Shin told AFP news agency.
"For the North, it can also show to the world, especially the US, that Beijing has Pyongyang's back if the North's ties with the US sour in the future," Mr Shin said.
North Korean officials have also visited China recently to learn about its economic reforms - yet another sign of Pyongyang's reliance on Beijing for its economic well-being.
"We are happy to see that the DPRK made a major decision to shift the focus to economic construction, and the development of the DPRK's socialist cause has entered a new stage in history," Mr Xi told Mr Kim, according to China's official Xinhua news agency.
China has backed United Nations sanctions against its ally but indicated last year that the UN Security Council could consider easing the punitive measures.