Mao Zedong once said China and North Korea, longtime Communist allies, were as “close as lips and teeth.”

But relations between the two countries have been strained in recent decades. However, there was no hint of that tension in the coverage of Mr. Kim’s visit this week.

The Chinese and the North Korean news media portrayed the two countries as ideological comrades. Mr. Kim was welcomed in the Great Hall of the People in Beijing, as a military band played. News reports said he and Mr. Xi watched an art performance together, joined by their wives.

Orville Schell, director of the Center on U.S.-China Relations at Asia Society in New York, described the pageantry as a “renaissance of the old socialist-style, big-leader rituals.”

“They certainly didn’t just sneak him in the back door,” he said of Mr. Kim. “It looked like he got pretty close to the full monty.”