DALIAN, China — The leaders of China and North Korea met for the second time in two months on Tuesday, staying overnight in this Chinese port city as China worked to regain control in the fast-moving diplomacy over the North’s nuclear program.

The North Korean leader, Kim Jong-un, flew to Dalian on Monday, where he held long rounds of discussions with Chinese officials, attended a formal banquet, and took a stroll on a beachfront sidewalk with China’s president, Xi Jinping. The pageantry was shown at length on China’s state-run evening television news, with the two men looking like friends, if rather stiff ones.

The Chinese leader appeared intent on showing that the frayed relationship with North Korea was now repaired, and that China was as important to resolving the problems of North Korea’s nuclear weapons as the United States.

President Trump has said he will meet with Mr. Kim in the coming weeks, and tweeted hours after the meeting in Dalian that he expected to talk shortly on the phone with Mr. Xi about North Korea, as well as trade.