BEIJING — They stood shoulder to shoulder in a sleek, open-air Mercedes, waving at cheering crowds in the North Korean capital, Pyongyang. They watched a propaganda spectacle in a stadium, chatting all the while. And the visitor was greeted with a candy-colored banner hailing him as Grandpa Xi.

Outward signs seemed to suggest a patching-up of the tattered relationship between two allies and neighbors, as North Korea’s leader, Kim Jong-un, hosted President Xi Jinping of China this week. It was the first time a Chinese leader had stepped onto North Korean soil since 2005.

But behind the public bonhomie, there was little to suggest that the visit — which lasted barely 24 hours — heralded any real change in the relationship between the North and its one major ally. Both leaders were seeking leverage in their separate disputes with the United States, analysts said, and the meeting seemed hastily arranged to precede Mr. Xi’s expected talks with President Trump in Japan next week.

Mr. Kim, for his part, had a longer-term goal: a good relationship with the United States that would free the North of its economic dependence on China, said John Delury, an associate professor of Chinese studies at Yonsei University in Seoul, South Korea.