Kim Jong Il's death conjures up several nightmares for China, including turmoil in neighboring North Korea or _ equally unpleasant in Beijing's eyes _ a political pivot that puts Pyongyang into the embrace of South Korea and the U.S.
China has deep concerns over the kind of chaos in North Korea that could send a surge of starving, desperate refugees across its border. But it also fears any eventual Korean unification dominated by South Korea, which would put a pro-Western government on China's northeast border, and end its near-total dominance of the North Korean economy.
"If North Korea becomes less intransigent and even slightly more open, then China will be greatly worried about the possible warming up, or even reunification, between North and South Koreas," said U.S. Naval Academy China scholar Yu Maochun.
Those concerns are prompting Beijing to take a strong behind-the-scenes role in the North Korean succession in hopes of heading off any changes that challenge its pre-eminence there, Yu said.
Publicly, China has sought to reassure North Korea of Beijing's continuing support in an apparent bid to ensure a stable transition of power from from Kim _ the country's ruler for 17 years _ to his son and anointed successor, Kim Jong Un.
A day after Monday's announcement of Kim's death, Chinese President Hu Jintao and other top leaders visited North Korea's embassy in Beijing to offer condolences. China called Kim a "close friend" and hailed Kim Jong Un as North Korea's new leader.
China even invited the next leader to visit soon.
A visit by the younger Kim would offer yet another chance for Beijing to convince the North of the attractions of its own model of market-oriented economic reform accompanied by iron fisted one-party political control. The elder Kim never fully embraced that approach _ despite numerous visits to China _ because he was unwilling to risk losing his absolute political grip.
The North has made a few halfhearted stabs at a more market-oriented economy, recently agreeing to set up a joint economic development zone on an island in the Yalu River along the border with China.
Beijing now hopes reforms will be launched in earnest, although experts expect a period of caution and policy paralysis while the younger Kim consolidates his rule.
Despite the sickly nature of the North's economy, Chinese businesses have found opportunities, and few or no competitors.
Such advantages snowballed after economic links with South Korea were severed in recent years. China now accounts for about 83 percent of North Korea's international commerce, up from about 53 percent in 2005, according to the Seoul-based Korea Trade-Investment Promotion Agency.
Chinese companies are the main investors in North Korean mining, and key players in the country's infrastructure.
At the sprawling free trade market in the North Korean city of Rason near the border with China, most of the goods sold _ from slippers and lipstick to refrigerators and mobile phones _ are Chinese, hauled from China on a road Chinese construction workers repaved this year.
Possible Chinese investment in a coal-fired power plant is being hammered out and Rason is exploring how to buy electricity directly from the Chinese side by snaking power lines across the river border.
Such economic influence augments China's political leverage over North Korea.
China is North Korea's biggest source of food and fuel assistance and helps water down or deflect sanctions over the North's nuclear programs. Beijing refused to criticize Pyongyang over the deadly sinking of a South Korean navy ship and bombardment of a front-line island.
But China's influence over the fiercely independent and highly unpredictable North Korean regime should not be overstated, said David Reeths, a former U.S. Naval intelligence officer and senior adviser with IHS Jane's Consulting.
Beijing was unable to deter Pyongyang from its provocations against the South, and the North still harbors "tremendous suspicion about China's ultimate aims," Reeths said.
Another major question is to what degree China would be willing to coordinate with South Korea, the U.S. and Japan in responding to any turmoil in North Korea, an issue over which Chinese scholars are deeply divided.
Out of suspicion and fear of tainting relations with Pyongyang, Beijing never joined in any multinational contingency planning over a potential North Korean crisis, said Gong Keyu, a Korea expert at Shanghai's Institute for International Studies.
"China doesn't want its secrets leaked," Gong said.
While the nationalist media have called on China to go its own way on North Korea, some scholars have said China should discuss possible responses to an emergency, saying that was the best way to avoid friction and potential conflicts. China officially eschews military alliances, but holds joint drills and regular military consultations with a wide range of nations.
An implosion of North Korea's government could not only bring a flood of refugees crossing into China, it could threaten the entire region by leaving the North's nuclear facilities vulnerable, leading to what Carla Freeman of Johns Hopkins University's School of Advanced International Studies called "loose nukes."
A response to either scenario could see Beijing doing something it hasn't done since the 1950-53 Korean War: send troops onto North Korean soil, to deal with the refugees or secure the country's nuclear facilities.
That could further inflame regional tensions, if the Chinese forces should come into contact with South Korean or American forces without any prior coordination, Freeman warned.
"One can only hope that the major stakeholders _ China, South Korea, and the U.S. _ will communicate with each other about how they work together in such a scenario," she said.
Associated Press reporter Alexa Olesen contributed to this report.