BEIJING — China, North Korea’s foremost ally, appears to be moving quickly to try to ensure stability in a crippled and isolated nation now facing a leadership transition fraught with dangers.

According to former government officials and analysts, both Chinese and foreign, China’s leaders had been hoping that Kim Jong-il, who died on Saturday, would live for at least two or three more years to solidify the succession process that he had begun with his youngest son, Kim Jong-un. Uncertainty now looms, not only over whether the younger Kim can consolidate his power in the face of competing elite factions, but also over whether the elder Kim’s economic initiatives will continue, which had included several visits to China to study it as a model for possible economic reforms.

So, the analysts and former officials say, the Chinese are seeking to deepen their influence over senior North Korean officials, particularly in the military, and to use the channels they have kept open with North Korea even as the West, frustrated over its nuclear intransigence, closed doors. China’s highest priority is one shared far more broadly: guarding against a rise in tensions on the divided Korean Peninsula. That is a distinct possibility if North Korean generals try to reinforce their hold on power through aggression toward South Korea.