Kim Jong-un, North Korea’s ruler, greeted President Xi Jinping of China this week with the pomp and ceremony befitting the leader of the North’s oldest ally, closest friend and largest trading partner.

Chinese leaders rarely visit North Korea, a country frequently described in the Western news media as “isolated” and a “pariah.” But Mr. Xi’s visit on Thursday and Friday came at a critical time for both the North and China, with each country locked in a stalled dispute with the United States.

Mr. Xi, like his young North Korean counterpart, is routinely called a friend by President Trump. Nevertheless, Mr. Trump has leaned increasingly hard on both leaders to cut deals and has threatened severe consequences for failing to do so.