SEOUL, South Korea — The last time a Chinese leader visited North Korea — when President Hu Jintao went in 2005 — he and Kim Jong-il, then the North’s leader, kept up a tradition by hugging three times at the airport, their cheeks touching.

On Thursday, when President Xi Jinping of China visits Mr. Kim’s son and successor, Kim Jong-un, there may not be that degree of affection. But with both leaders in separate confrontations with the Trump administration — one over trade, the other over nuclear weapons — they may need each other more than their predecessors did.

“Until now, we have not seen Xi giving the same warm regard to Kim Jong-un, his junior by 31 years, although they have met four times,” said Lee Seong-hyon, an analyst at the Sejong Institute in South Korea, comparing the leaders’ relationship to that of their predecessors.

“But China and North Korea are now finding more common ground than ever, driven by their common adversary: the United States,” Mr. Lee said. “As the trade war between Beijing and Washington intensifies, North Korea’s geopolitical value to China has only increased.”