Still, the odds of North Korea shifting its allegiance toward the United States are not great, Western experts say. That is particularly true in the era of President Trump, who is seen as an uncertain partner even for Washington’s existing Asian allies.

“North Korea has no reason to believe that the U.S. would be willing or able to defend it from China,” said Hugh White, an Australian defense strategist. “Who in Pyongyang would believe that America could fight and win a land war against China on China’s borders?”

Rather, Mr. Kim is more likely to be looking for ways to increase his level of independence from China, a desire that has recently been shown by a meeting with the Russian foreign minister, Sergey V. Lavrov, and by reports that the Syrian leader, Bashar al-Assad, is planning to visit Pyongyang.

“Like any middle power, Kim is aiming to be independent of any great power — both China and America — and he is already a fair way towards that goal,” Mr. White said. “That’s what the nukes are for. What Kim wants is to keep as much of his independence as possible and hence as much of his nuclear capability as possible.”

For Mr. Kim, an embrace of the United States would also have its limits.

Although Mr. Trump has chosen largely to ignore the human rights abuses in North Korea, there is still enormous hostility in Washington toward what remains a Communist dictatorship. Some members of Congress and of Mr. Trump’s administration, including his national security adviser, John R. Bolton, have advocated regime change in the North.

Mr. Kim would also have little reason to expect economic help from the United States. After North Korea’s second-most powerful figure, Kim Yong-chol, visited him in the Oval Office, Mr. Trump said he had no intention of helping the North build its backward economy, a job that he said belonged to China and South Korea. “That’s their neighborhood,” Mr. Trump said.

Already, trade across China’s border with North Korea is stepping up. Last week, the state airline, Air China, renewed flights to Pyongyang after a six-month hiatus.