The death of North Korean leader Kim Jong Il on Dec. 17 is expected to cause concern within China, its massive neighbor and only major ally. While Kim was known to be frail, particularly after a 2008 stroke, his condition had appeared to stabilize, and Chinese leaders were under the impression that he “was in better health than was the case,” says Stephanie Kleine-Ahlbrandt, Northeast Asia project director for the International Crisis Group. “His death is very unexpected, and they will be understandably alarmed.”

Of particular concern to China is whether Kim’s death will make North Korea, long a source of instability in the region, even more unpredictable. “No one should say the possibility will be high for North Korea to implode, but no one can neglect the potential risk of that sort of domestic tension and unrest,” says Zhu Feng, an international-relations scholar at Peking University. The transition to the deceased dictator’s appointed heir, his third son Kim Jong Un, also comes in a year when China is expected to carry out its own long-planned change of top leaders, adding to the concerns in Beijing. “The Chinese have always prioritized stability and particularly at this moment want nothing to interfere with their own preparations for leadership transition,” says Kleine-Ahlbrandt.

The pressure stems from China’s unique relationship with North Korea. It is the North’s largest provider of food aid, a key trading partner and a weapons supplier for its military. China also maintains rigorous control of its border with the North, sending back defectors, whom it considers “economic migrants”; to help stem the flow, it has tried to push Pyongyang to adopt economic reforms of the sort that helped China grow into the world’s second largest economy. (Kim Jong Il always remained wary of the threats to his authority that could arise from a market economy, however, and backed away from any significant reform.)

The help isn’t limited to the domestic sphere. By hosting the long-running six-party talks on North Korean denuclearization, Beijing facilitates North Korea’s dealings with other nations. That’s a job it will have to focus on intensely during the North Korean leadership transition. “Beijing has a key role to play because it has the best channels politically and militarily with Pyongyang,” says John Delury, an assistant professor at Yonsei University’s Graduate School of International Studies in South Korea. “There’s a lot of weight on their shoulders because, for the time being, they are the new North Korean leadership’s door to the outside world.”

The relationship between North Korea and China was forged in the 1950–53 Korean War, when the two nations, backed by Soviet aid, battled U.S.-led U.N. forces to a bloody stalemate. The legacy of that conflict remains an important part of their ties. In October 2010 Xi Jinping, the leading candidate to succeed Chinese President Hu Jintao in the leadership transition that begins next year, called the war, which killed an estimated 4 million people, “a great and just war for safeguarding peace and resisting aggression.” That contravened the widely held understanding, backed up by documents in Soviet archives, that the war was started by North Korean forces. Also in October 2010 In October 2009 Chinese Premier Wen Jiabao visited a memorial in North Korea for Mao Anying, a son of Mao Zedong who died while fighting as a volunteer in the conflict, which is officially known in China as the War to Resist U.S. Aggression and Aid Korea.

In North Korea itself, the war has never officially ended but is merely considered to be at a cease-fire. That keeps Pyongyang in a perpetual state of military readiness. It has relentlessly pursued nuclear capability (testing devices in 2006 and ’09), maintains one of the world’s largest standing armies and makes official decisions under a policy of songun (military first). The demilitarized zone between North and South Korea is, despite its name, the most fortified border in the world, with territorial conflict an ever present danger. In March 2010, a South Korean navy corvette was sunk by a torpedo in disputed waters, killing 46 sailors in an attack that Seoul blamed on the North. In November 2010, North Korea shelled a South Korean island, killing two South Korean soldiers.

The provocations put pressure on Beijing to reprimand its ally, but while Chinese officials made calls for peace on the Korean Peninsula in both cases, they stopped short of publicly condemning Pyongyang. The traditional bonds with the North and the desire to maintain a buffer state between China and U.S.-fortified South Korea mean that Beijing is unlikely to break with Pyongyang. “The North Korea issue has always been controversial for China,” says Zhu. “We see a totalitarian regime that causes trouble for China with its nuclear ambitions and its provocative behavior, but based on proximity and traditional and historical links, Beijing can’t abandon the North. There’s no single policy divide in China greater than North Korea.”

On Monday, Dec. 19, the Politburo of the Chinese Communist Party, the country’s top ruling body, sent condolences to its North Korean counterpart, saying Kim “gave his life’s energy to the great cause of establishing a rich and powerful, Korean-style socialist nation.” Beijing also endorsed Pyongyang’s succession plans, saying it hoped that North Korea, “under the leadership of Comrade Kim Jong Un, will turn grief into strength and build a powerful socialist country.”

Public sentiment in Beijing has been less effusive, however. On Monday at the North Korean embassy, where the flag flies at half-mast, a handful of people could be seen weeping and walking briskly out a side entrance. A nearby North Korean–run restaurant was closed in mourning. Few people noticed or cared. Instead, the citizens of North Korea’s only real ally seemed far more interested in the deals at the Walmart next door.