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, a