Other major hurdles litter Chinaâs path. The United States, despite signs of retreat in Asia under the Trump administration, remains the dominant military power. And India and Japan, Chinaâs traditional rivals in the region, have made clear that they intend to resist its gravitational pull.
Yet North Korea â an outcast of the international order that Beijing hopes to lead, but also a nuclear state in part because of Chinaâs own policies â presents a particularly nettlesome challenge.
Chinaâs path to dominance requires an American withdrawal and a message to American allies that they cannot count on the United States for protection. But North Korea threatens to draw the United States more deeply into the region and complicate Chinaâs effort to diminish its influence and persuade countries to live without its nuclear umbrella.
At the same time, the strategic location of the North â and its advancing nuclear capabilities â makes it dangerous for China to restrain it.
âNorth Korea may not be the biggest problem to China, but it does add a unique and very serious dimension to Chinaâs task of supplanting America in East Asia,â said Hugh White, a former strategist for the Australian Defense Department. âThatâs because it is the only East Asian power with nuclear weapons.â
Even if the United States steps back from the region, Mr. White added, âNorth Koreaâs capability means China can never be able to dominate the region as much as its leaders today probably hope.â
The Trump administration has bet on China to stop North Koreaâs nuclear program, shunning talks with Mr. Kim and gambling that Beijing can be persuaded to use its economic leverage over the North to rein it in.
But in doing so, the White House may be misreading the complexity of Chinaâs relationship with North Korea, one that successive generations of Chinese leaders have struggled to manage.
A New Cold War
There is growing resentment against Mr. Kim inside China, both in the general public and the policy establishment. China keeps North Korea running with oil shipments and accounts for almost all its foreign trade. But to many Chinese, the young leader seems ungrateful.
A three-day academic seminar in Shanghai last month brought together some critics, who question North Koreaâs value to Beijing as a strategic buffer against South Korea and Japan â and warn that the North could prompt them to develop nuclear weapons of their own.
âThe cost is to continue to alienate Japan, enrage the United States and irritate South Korea,â said Zhu Feng, a professor of international relations at Nanjing University. âIf Japan and South Korea feel forced to go for radical options like nuclear weapons, it will badly affect regional diplomacy.â
The spread of nuclear weapons, he added, would thrust China into âa new Cold Warâ in Asia, perhaps with a beefed-up American military presence. That would frustrate Beijingâs ambitions for regional supremacy while also leaving it vulnerable to being labeled an enabler of nuclear proliferation, tarnishing its international reputation.
âA balance of mutually assured destruction in Northeast Asia will not be a satisfactory situation for anyone,â said Bilahari Kausikan, a former foreign secretary for Singapore. âBut it will not necessarily be unstable, and it may be of some small consolation to Washington, Tokyo and Seoul that the implications for Beijing are somewhat worse.â
President Xi Jinping is said to be aware of such risks and to have privately expressed disdain for Mr. Kim.
But like his predecessors, he has resisted punishing sanctions that might cause North Koreaâs collapse and lead to a destabilizing war on its border, a refugee crisis in Chinaâs economically vulnerable northeast, or a unified Korean Peninsula controlled by American forces.
All these possibilities could pose as much a problem for Chinaâs plans for ascendancy in Asia as an arms race in the region. And if North Korea somehow survived, it would remain on Chinaâs border, angry and aggrieved.
From Mr. Xiâs perspective, a hostile neighbor armed with nuclear weapons may be the worst outcome.
The Pakistan Connection
China has more nuclear-armed neighbors than any country in the world: Russia, India, Pakistan and now North Korea. But that situation is partly one of its own making.
The origins of North Koreaâs nuclear program can be traced to a deal in 1976 between an ailing Mao Zedong and Zulfikar Ali Bhutto, then the prime minister of Pakistan.
India had tested its first nuclear bomb two years earlier, and Mr. Bhutto wanted to keep up. China viewed India as a potential threat; the two had fought a brief border war. So it agreed to help.
The particulars were ironed out by Pakistani visitors to Maoâs funeral, according to the account of A. Q. Khan, the nuclear physicist who founded the uranium enrichment program of Pakistanâs bomb project.
In 1982, China shipped weapons-grade uranium to Pakistan. And in 1990, it opened its Lop Nur test site to Pakistan and secretly let the country test its first nuclear bomb there, according to âThe Nuclear Express,â a book by two veterans of the American nuclear program.
The United States, upset by Chinaâs behavior, including its sale of missile technology across the developing world, pressed it behind the scenes to stop and persuaded it to sign the Nuclear Nonproliferation Treaty in 1992.
But Beijingâs recognition of the risks of proliferation came slowly, and the genie was already out of the bottle. In 1998, when India conducted five nuclear tests, Pakistan responded with a public test of its own less than three weeks later.
At about the same time, Pakistan was sharing nuclear enrichment technology with North Korea â including centrifuges, parts, designs and fuel essential for its nuclear bombs â in exchange for Korean missile technology and design help. Pakistan later accused Mr. Khan of acting on his own, but he maintains that he had the governmentâs blessing.
By 2002, the trade was so brazen that Pakistan sent an American-made C-130 cargo plane to North Korea to collect a shipment of ballistic missile parts, a flight that was detected by United States satellites.
Some analysts argue that Beijing was complicit in the deal, either encouraging Pakistan to share nuclear technology with North Korea or looking the other way as it happened. China allowed the transfers to occur through Pakistan to maintain plausible deniability, they say.
âMy guess is that most Western analysts, perhaps a bit cynically, would assume that Chinese officials were fully aware of the nuclear trade, given the strong ties between the Pakistani and Chinese nuclear establishments,â said Toby Dalton, a nuclear nonproliferation expert at the Carnegie Endowment for International Peace and a former official at the Energy Department.
âI think it is fair to assess that North Korea wouldnât be where it is today without the earlier trade with Pakistan,â he added. âBut given Pyongyangâs determination to have nuclear weapons, it wouldnât be that far behind.â
Others say that while there is no doubt that China helped Pakistan acquire the bomb, Beijing would not have wanted that know-how passed on to North Korea.
âFor China, assisting Pakistanâs nuclear program has had clear strategic benefits,â said Daniel S. Markey, an expert on Pakistan at Johns Hopkins University. âBut the onward proliferation to North Korea was almost certainly an unintended consequence not foreseen by Beijing.â
While China wanted Pakistan to counterbalance India, it is less clear how it would have benefited from the Northâs obtaining nuclear technology. Beijingâs ties with South Korea were improving at the time, but its relationship with the North had hit a rocky patch â again.
Blood and Betrayal
Mao is often quoted in the West as saying that North Korea and China are âas close as lips and teeth.â But his actual words, an ancient Chinese idiom, are better translated, âIf the lips are gone, the teeth will be cold.â He was warning that China would be in danger without North Korea.
In 1950, Mao sent more than one million Chinese soldiers, including his own son, into the Korean War to help the North fight the United States. By the time the armistice was signed three years later, more than 400,000 Chinese troops had been killed and wounded, a sacrifice in blood that one might have expected to forge a lasting loyalty between the two countries.
But there has always been an edge to the relationship, bred at the start by two Communist rivalries â between Mao and North Koreaâs founder, Kim Il-sung, and between Mao and Stalin, who both saw themselves as overlords of the new state created after World War II.
Then Kim showed who was in charge, purging a faction of senior leaders with Soviet connections in 1955 and moving the next year against more than a dozen members of an elite North Korean military group with ties to Mao. Several were arrested while a handful escaped to China.
The Soviets urged Mao to join them in retaliating against Kim. Chinese troops had not fully withdrawn from the North yet. But Mao demurred, according to a recent article by Sergey Radchenko, a professor of international studies at Cardiff University, citing newly declassified documents from Russian archives.
For the most part, Mao tolerated North Koreaâs displays of disloyalty because he was afraid of losing it to the Soviet Union, which was the Northâs main economic benefactor and provided it with aid that Mao could not match.
After the collapse of the Soviet Union, though, China enjoyed more room to maneuver. In 1992, seeking trade, it established diplomatic relations with South Korea, infuriating the North, which was suddenly poorer and more isolated than ever.
From then on, according to Shen Zhihua, a historian of Chinese-Korean relations, âThe treaty of alliance between China and North Korea became a piece of scrap paper.â
China now imports more goods from South Korea than it does from any other country, while the South counts China as its largest market for both exports and imports. One of Mr. Xiâs first foreign policy initiatives sought to take advantage of those ties and weaken the South Korean alliance with the United States.
But North Korea got in the way. After the North conducted its fourth nuclear test in early 2016, South Koreaâs president at the time, Park Geun-hye, tried to call Mr. Xi to ask for his help in restraining Kim Jong-un.
Ms. Parkâs aides were unable to arrange the call, according to local news reports. Chinese analysts said Mr. Xi was unwilling to accept Ms. Parkâs demand for âthe most severeâ sanctions against the North.
By refusing to abandon Pyongyang, Mr. Xi lost ground in Seoul.
Ms. Park strengthened relations with Washington and agreed to deploy a missile defense system that Beijing opposed.
For more than a decade, the United States has asked China for talks to discuss what each nation would do if North Korea collapses â but China has resisted, worried that agreeing to do so would be a betrayal.
Among the most pressing questions: Where are the Northâs nuclear weapons and who would secure them? How would the two countriesâ military forces avoid clashing as they raced to do so? And what should the Korean Peninsula look like afterward?
The Pentagon has asked Beijing to discuss such âcontingency plansâ since the presidency of George W. Bush, but on each occasion, the Chinese response has been silence, according to a former United States defense official, who requested anonymity because he was not authorized to speak on the subject.
âThe Chinese are concerned about how the North Koreans would react,â said Ralph A. Cossa, the president of the Pacific Forum CSIS in Honolulu. âI think it stops the conversation in the room.â
In a rare departure, Chinese military officials expressed an interest in the subject in 2006, the year the North conducted its first nuclear test, said an American official familiar with the conversations. But the Pentagon was suspicious that the Chinese were seeking to learn as much as possible about the United Statesâ plans without revealing their own thinking, the official said.
As tensions have climbed in recent weeks, questions about what China would do in a crisis remain unanswered. But there is a broad understanding that Beijing would be opposed to American forces crossing the 38th parallel that divides North and South Korea.
Global Times, a state-owned tabloid that reflects the opinion of some segments of the party elite, published an editorial last month warning North Korea that China would remain neutral if it attacked the United States.
But the editorial also said that China was prepared to stop any attempt by American and South Korean forces âto overthrow the North Korean regime and change the political pattern of the Korean Peninsula.â
âThe common expectation,â said Yun Sun, a scholar at the Stimson Center in Washington, âis that China is prepared to intervene to preserve a functional North Korean government, as well as the survival of North Korea as a country.â
American research institutes regularly convene âtabletop exercisesâ about North Korea â meetings in which participants are divided into teams representing different nations and asked to discuss how they would respond in a simulated emergency situation.
One analyst who has led these drills said the mutual suspicions run deep: The two teams representing China and the United States often end up shooting at each other.
On occasion, Chinese scholars and retired military officers agree to participate in the sessions. But Phillip C. Saunders, the director of the Center for the Study of Chinese Military Affairs at the National Defense University, said they usually emphasized two well-worn points:
The North Korean government is stable, and Chinaâs influence over North Korea is limited.