- Shortly after the capital fell to the Taliban, a spokesperson for China's foreign ministry said Beijing is "ready to develop good-neighborliness and friendly cooperation" with the Afghanistan.
- The relationship between China and the Taliban is "tricky" because Beijing targets what it sees as religious extremism among Muslims in Xinjiang, said Ian Johnson of the Council on Foreign Relations.
- Chinese authorities may also be trying to protect their country from terror attacks by building a relationship with the Taliban, said Neil Thomas, China and Northeast Asia analyst at Eurasia Group.
China was one of the first countries that expressed willingness to engage with Taliban militants diplomatically when they swept to power in Afghanistan — analysts say it's a pragmatic move, but relations could be "tricky" considering Beijing's strategic interests.
Beijing has for years been preparing for the possibility of the Taliban's return to power, according to Derek Grossman, a senior defense analyst at Rand Corporation.
"Unofficially, they've been speaking with the Taliban for many years now, hedging their bets," he told CNBC's "Squawk Box Asia" on Wednesday.
But the relationship between China and the Islamist militant group is "tricky" because Beijing targets what it calls religious extremism among ethnic minority Muslims in Xinjiang, said Ian Johnson of the Council on Foreign Relations.
China and Afghanistan share a border.
Hours after the capital of Kabul fell into the hands of the Taliban, a spokesperson for China's foreign ministry said Beijing was "ready to develop good-neighborliness and friendly cooperation" with Afghanistan.
Spokesperson Hua Chunying said Beijing welcomed the Taliban's statements about wanting "to grow sound relations with China." The militant group also said it looked forward to China's participation in the reconstruction and development of Afghanistan.
In July, Chinese Foreign Minister Wang Yi met with the head of the Afghan Taliban political commission, Mullah Abdul Ghani Baradar.
Xinjiang is home to the minority Uyghur Muslims. The United States, the United Kingdom and the United Nations have accused China of human rights abuses including forced labor and large-scale detentions in Xinjiang. Beijing denies those claims.
"If they have an Islamist political party that is … running a neighboring country, that could be, potentially, a problem for China," said Johnson, who is the CFR's Stephen A. Schwarzman senior fellow for China studies.
"At least optically, it seems kind of weird that, on the one hand, Beijing … would be willing to work with [the Taliban]. On the other hand, Islamist groups in Xinjiang are such a problem," he told CNBC.
China is worried that Afghanistan will become a haven for an Uyghur extremist group called the East Turkestan Islamic Movement, according to a Eurasia Group note. Beijing believes the group could launch attacks in response to the "widespread repression of Uyghurs," analysts wrote.
Chinese authorities may be trying to protect their country from terror attacks by building relations with the Taliban, according to Neil Thomas, China and Northeast Asia analyst at Eurasia Group.
"Beijing hopes that offering economic assistance and possibly diplomatic recognition to the Taliban will persuade them to protect China's security interests in Afghanistan," he told CNBC in an email.
China's decision to engage with the Taliban is a "pragmatic move," Thomas said.
It makes "perfect sense" for Beijing, according to Rodger Baker, senior vice president of strategic analysis at Stratfor.
"We've seen around the world — the Chinese are perfectly willing to deal with any side that's in a country, so long as that side agrees to keep China's interests," he told CNBC's "Squawk Box Asia" on Wednesday. That may include keeping the region stable so that China's Belt and Road infrastructure projects will not be derailed, and preventing terrorism or other attacks, he added.
Hua, the foreign ministry spokesperson, said China has maintained contact and communication with the Taliban "on the basis of fully respecting the sovereignty of Afghanistan and the will of all factions in the country." The Taliban assured Beijing that it would "never allow any force to use the Afghan territory to engage in acts detrimental to China," she added.
"China will try to hold the Taliban to its word but there are unanswered questions about the unity and the level of extremism in the new regime," Thomas said.
China has "laid the groundwork" and made preparations to work with the Taliban, but it's difficult to predict whether Beijing will formally recognize them as Afghanistan's government, said Johnson of the CFR, adding that Western countries may not want anyone to affirm the Taliban.
"It may take a little bit of time," he said. Beijing "might want to see assurances that the Taliban is going to be 'a normal government' and not … have massacres and massive killings or something like that before they give them formal diplomatic recognition."
If the Taliban behaves "more or less normally," China is likely to recognize it "at some point" before Western countries, he added.
Rand Corporation's Grossman echoed that sentiment, noting that China may think it's time to start the process of potentially recognizing the Taliban as a "legitimate governing entity."
"But they've also said that they want to make sure that the Taliban is making a 'clean break' with terrorist proxies," he said.
The Taliban last week pledged peace at its first press conference since taking Kabul, according to a Reuters report.
For now, unlike many other governments who have moved to evacuate embassy staff from Afghanistan, China's ambassador remains in Kabul. A spokesman for the Taliban's political office reportedly said the group would not target diplomatic missions in the country.
It's smart of China to take this approach, which signals that Beijing is not scared, taking sides or running away from the Taliban, said Johnson.
Eurasia's Thomas said that could also help in the medium term.
"It's possible that China asked its diplomats to stay in Afghanistan to present a contrast with evacuating Western missions and try to build trust and diplomatic leverage with the incoming Taliban regime," he said.