Editor’s Note: A version of this story appeared in CNN’s Meanwhile in China newsletter, a three-times-a-week update exploring what you need to know about the country’s rise and how it impacts the world. Sign up here.

Hong Kong CNN  — 

As China watches the chaotic scenes unfold in the Afghan capital Kabul, it is likely seeing more imminent risk than opportunity.

Since US President Joe Biden announced in April a full withdrawal of American troops from Afghanistan, there has been much talk about how China could seize the moment to fill the vacuum left behind by the US and expand its presence and influence there.

Such arguments have only intensified following the high-profile meeting between Taliban leaders and Chinese Foreign Minister Wang Yi last month, where Wang declared the Taliban would “play an important role in the process of peaceful reconciliation and reconstruction in Afghanistan.”

But for China, a neighbor of Afghanistan with substantial investment in the region, the security challenges posed by the abrupt return of the Taliban are far more pressing than any strategic interests down the road.

“China does not tend to perceive Afghanistan through the prism of opportunities; it is almost entirely about managing threats,” said Andrew Small, a fellow at the German Marshall Fund in Washington, in an interview with the European Council on Foreign Relations.

Beijing had long been wary of the American military presence in Afghanistan, which shares a 50-mile (80 kilometer) border with China’s western region of Xinjiang at the end of the narrow Wakhan Corridor. But in reality, China has also benefited from the relative stability brought by the US over the past two decades.

China is particularly concerned that Afghanistan would become a base for terrorists and extremists fighting for the independence for the largely Muslim region of Xinjiang — a priority issue Wang raised with Taliban leaders during their meeting last month. In response, the Taliban pledged that it would “never allow any force to use the Afghan territory to engage in acts detrimental to China.”

But the security risks are not bound to China’s borders. In recent years, China has invested heavily in Central Asia through its Belt and Road trade and infrastructure program. A spillover effect of the Taliban’s rise to power on Islamist militants could potentially threaten Chinese economic and strategic interests in the wider region.

“Although Beijing is pragmatic about the power realities in Afghanistan, it has always been uncomfortable with the Taliban’s ideological agenda,” Small said. “The Chinese government fears the inspirational effect of their success in Afghanistan for militancy across the region, including the Pakistani Taliban.”

That security threat was underscored last month when nine Chinese workers were killed in a suicide bombing in Pakistan — one of the deadliest attacks on overseas Chinese nationals in recent years. Islamabad said the attack had been carried out by “the Pakistani Taliban out of Afghanistan.”

Beijing’s unease with the potential fallout in Afghanistan was reflected in statements from its Foreign Ministry, which has repeatedly criticized the US for acting “irresponsibly” in its “hasty withdrawal.”

But Beijing has also signaled that it has no intention in sending troops into Afghanistan to fill the power vacuum left by the US, as some analysts have suggested. In an article Sunday, the state-owned Global Times cited experts as saying such speculation is “totally groundless.”

“The most China can do is to evacuate Chinese nationals if a massive humanitarian crisis occurs, or to contribute to post-war reconstruction and development, pushing forward projects under the China-proposed Belt and Road Initiative (BRI) when safety and stability are restored in the war-torn country,” the article said.

Chinese state media has painted the situation in Afghanistan as a major “humiliation” for the US, and used it to argue for the superiority of China’s so-called policy of “non-inteference” in other countries’ internal affairs — part of its key foreign policy principles as laid down by former Chinese Premier Zhou Enlai in the 1950s.

“The drastic change in Afghanistan’s situation is undoubtedly a heavy blow to the US. It declared the complete failure of US intent to reshape Afghanistan,” the Global Times said in an editorial published late on Sunday night. “This defeat of the US is a clearer demonstration of US impotence than the Vietnam War — the US is indeed like a ‘paper tiger.’”

Beijing is well aware of the costs of being entangled in the security situation of Afghanistan — multiple recent state media analyses have referred to the country as the “graveyard of empires.”

Instead of following in the footsteps of the US, China is likely to adopt a pragmatic approach toward Afghanistan. By publicizing the Taliban delegation’s visit to China last month, Beijing is sending the message that it is willing to recognize and deal with a Taliban government, as long as it suits its interests.

On Monday, China’s Foreign Ministry said it hoped the Taliban can fulfill its promises to ensure the “smooth transition” of the Afghan situation and “curb all kinds of terrorist and criminal acts.”

“The situation in Afghanistan has undertaken major changes, we respect the will and choice of the Afghan people,” ministry spokesperson Hua Chunying said at a press conference.

Beijing’s confidence in dealing with the Taliban is reflected on the ground in Kabul. As the US and its allies scramble to evacuate embassies from Afghanistan, China — along with Russia — appears to be staying put.

In a statement Sunday, the Chinese embassy in Kabul said it had requested various parties in Afghanistan to “safeguard the safety of Chinese citizens, Chinese institutions and Chinese interests.” It said it had not received any reports of injury or casualty involving Chinese nationals, and reminded them to “closely follow the security situation, increase safety precautions and to refrain from going outside.”

At the press conference Monday, Hua confirmed the Chinese embassy in Kabul is still in operation, adding that it had evacuated the majority of Chinese nationals in Afghanistan in advance.