Just three months ago, China’s top leader, Xi Jinping, was in Moscow clinking glasses with Vladimir V. Putin and expressing his confidence in the “firm support” the Russian president enjoyed among his people.

That confidence is now in question, after the Wagner private military group waged an insurrection in Russia that has shaken Mr. Putin’s image of invulnerability. Close watchers of China say that the mutiny, short-lived as it was, could lead Mr. Xi to hedge a close relationship with Russia that had already exposed Beijing to global criticism and threatened some of its interests abroad.

China views Russia as a necessary partner in challenging the global order dominated by the United States. But Mr. Putin’s appetite for risk — seen in his invasion of Ukraine and his reliance on private armies — has forced Beijing to defend its bond with Russia in the face of Western pressure.

Mr. Xi’s long-term bet will work only if Mr. Putin remains in control to help uphold the shared interests of both countries. But the revolt has raised questions about Mr. Putin’s authority: Wagner soldiers faced little to no resistance from regular Russian forces as they advanced on Moscow. And Mr. Putin’s decision to grant sanctuary in Belarus to Yevgeny V. Prigozhin, the leader of the uprising, smacked of a compromise rather than the act of a strongman with consolidated power.

“It makes China realize that the Putin government’s internal politics are actually quite fragile,” said Xiao Bin, a researcher for the Institute of Russian, East European and Central Asian Studies at the Chinese Academy of Social Sciences. “The fragility existed before, but it has increased ever since the start of the Russia-Ukraine war.”

China has publicly reaffirmed its support for the Kremlin following the insurrection, and analysts say the relationship is likely to remain strong, at least on the outside, because of how the two leaders’ interests align.

But the mutiny has probably also forced Beijing to consider how its own geopolitical, economic and territorial interests would be affected if Mr. Putin were to suddenly be toppled. That could lead China to distance itself from Russia to some degree.

In the 23 years Mr. Putin has been in power, Russia’s relations with China have improved markedly from the Soviet era and the days of President Boris Yeltsin, when the two sides sent dozens of military divisions to face off against each other along the 2,600-mile border they share.

Any regime change in Russia now would prompt an instant reckoning for the relationship. China would be concerned that a new Russian leader would realign the nation toward a friendlier posture with the United States, Mr. Xiao said. That could leave China isolated in its rivalry with the United States and expose it to more pressure.

More extremely, a souring relationship between Beijing and Moscow could require China to again redeploy troops at the border with Russia, at the expense of other areas, said John Culver, a former U.S. intelligence analyst on China.

“Downsizing the number of troops along the border has allowed China to prepare for the greater potential for conflict over Taiwan or the South China Sea or with India,” Mr. Culver said. “I don’t think enough has happened to make them rethink that, but for the first time they have grounds to wonder if maybe they have to.”

Any instability in Russia would also be a warning to China about the urgency of protecting the country’s supply of Russian energy imports.

At the same time, a weaker Putin could be an opportunity for China to make some gains, said Wen-Ti Sung, a political scientist at Australian National University.

Beijing may consider accelerating efforts to extract more concessions from Russia. At the top of China’s list could be access to more Russian technology and more favorable terms for the proposed Power of Siberia 2 gas pipeline, which would help redirect Russian gas supplies that historically have gone to Europe toward China instead.

The questions about Mr. Putin’s political future highlight how differently he and Mr. Xi have approached their common goal of weakening U.S. global power and reshaping the global order to better protect their countries’ interests.

Mr. Putin has been far more aggressive, launching the biggest war in Europe since World War II. Mr. Xi has in recent years certainly taken a more bristling territorial stance, particularly with Taiwan, the self-ruling island democracy that Beijing claims, using economic sanctions and military drills to keep the island on edge. But he has so far been cautious to avoid tipping the standoff into a war that could draw in the United States and its allies.

Mr. Xi has also been focused on consolidating power at home. Starting in 2015, the Chinese leader began a major overhaul of the People’s Liberation Army to strengthen his grip over the military by ousting commanders deemed disloyal or corrupt and elevating his allies, in many ways to avoid the questions of loyalty Mr. Putin faces today.

Some see the Wagner rebellion as the latest sign that China’s relationship with Russia is increasingly similar to its relationship with North Korea, a country that is notoriously erratic, and that exploits its volatile behavior to try to press China for more support in exchange for backing down.

Ever since Russia invaded Ukraine, its trade with China has hit record highs. Beijing has also ensured that Moscow isn’t diplomatically isolated.

“Russia’s main incentive is to drive up the price of its friendship to get more out of its dealings with China,” Mr. Sung said. “Russia can do this when it appears reckless and unpredictable, not unlike North Korea.”

China has already paid a considerable price for its support for Russia. The war has worsened China’s fraught relations with the United States and undermined its bid to improve ties with Europe. The fighting in Ukraine has also drawn more global attention toward China’s aggressive stance on Taiwan.

China has navigated these drawbacks carefully at home. Chinese state media has downplayed the significance of what it called the “Wagner incident” and praised Mr. Putin for defusing the crisis. The Global Times, a Chinese Communist Party tabloid, accused Western media of “hyping” the rebellion to misrepresent China’s ties to Russia. There appeared to be no attention paid to Mr. Prigozhin’s claim that the Russian public was deceived into believing the North Atlantic Treaty Organization was responsible for the war.

“The Chinese government still believes in Putin’s control over Russia, and also believes in the long-term stability of Russian society,” said Wang Wen, the executive dean of the Chongyang Institute for Financial Studies at Renmin University in Beijing, who follows developments in Russia and visited the country after its invasion of Ukraine.

“It would be strategic misjudgment to think that the Wagner incident could divide China and Russia.”

Despite the mainstream support for Russia, other notable Chinese experts have argued that the war has harmed China’s position in the world, including Yan Xuetong, a senior international relations scholar at China’s prestigious Tsinghua University.

Speaking to reporters last month in Beijing, Mr. Yan noted that the United States had yet to send troops to defend Ukraine, but by comparison, European members of NATO had increased their presence in the Asia Pacific region.

“From a security perspective, this war has not enhanced China’s security but has subjected China to more security threats,” Mr. Yan said, according to a translation by the Pekingnology newsletter.

Chris Buckley contributed reporting from Taipei and Keith Bradsher from Beijing.