The Chinese State Councilor and Foreign Minister Wang Yi will meet with Mullah Abdul Ghani Baradar, the political head of the Afghan Taliban, in Tianjin, northern China, on July 28, 2021.

Li Ran | Xinhua News Agency | Getty Images

China was one of the first countries willing to diplomatically team up with Taliban fighters when they came to power in Afghanistan.

Beijing has been preparing for the possibility of a return of the Taliban for years, according to Derek Grossman, a senior defense analyst with the Rand Corporation.

“They have been talking to the Taliban unofficially for many years to hedge their bets,” he told CNBC’s “Squawk Box Asia” on Wednesday.

But the relationship between China and the militant Islamist group is “tricky” because Beijing is targeting so-called religious extremism among Muslim ethnic minorities in Xinjiang, said Ian Johnson of the Council on Foreign Relations.

On the one hand, Beijing would be … ready to work with [the Taliban]. On the other hand, Islamist groups in Xinjiang are such a problem.

Ian Johnson

External Relations Council

Xinjiang is home to the Uighur Muslim minority. The United States, the United Kingdom and the United Nations have accused China of human rights abuses, including forced labor and large-scale incarceration in Xinjiang. Beijing denies these claims.

“If you have an Islamist political party that rules … a neighboring country, that could potentially be a problem for China,” said Johnson, Stephen A. Schwarzman CFR Senior Fellow in China Studies.

“At least visually it seems somehow strange that on the one hand Beijing … would be willing to cooperate [the Taliban]. On the other hand, Islamist groups in Xinjiang are such a problem, ”he told CNBC.

Fear of extremist attacks

China fears Afghanistan will become a haven for a Uyghur extremist group called the East Turkestan Islamic Movement, according to a statement from the Eurasia Group. Beijing believes the group may launch attacks in response to “widespread repression against Uyghurs,” analysts wrote.

Chinese authorities could try to protect their country from terrorist attacks by building ties with the Taliban, according to Neil Thomas, an analyst for China and Northeast Asia for the Eurasia Group.

“Beijing hopes that economic support and possibly diplomatic recognition will convince the Taliban to protect China’s security interests in Afghanistan,” he said in an email to CNBC.

China’s decision to work with the Taliban is a “pragmatic move,” said Thomas.

According to Rodger Baker, Stratfor’s senior vice president of strategic analysis, it “makes perfect sense” for Beijing.

“We have seen all over the world – the Chinese are quite ready to deal with any side in a country as long as that side agrees to safeguard China’s interests,” he told CNBC’s “Squawk Box Asia” on Wednesday. This could include keeping the region stable so that China’s belt and road infrastructure projects are not derailed and terrorism or other attacks are prevented, he added.

Taliban members patrol the streets of the Afghan capital, Kabul, on August 16, 2021 as the Taliban take control of Afghanistan after President Ashraf Ghani fled the country.

Sayed Khodaiberdi | Anadolu Agency | Getty Images

Foreign Ministry spokesman Hua said China has maintained contact and communication with the Taliban “on the basis of full respect for the sovereignty of Afghanistan and the will of all factions in the country.” The Taliban assured Beijing that they “would never allow a force to use Afghan territory to act against China,” she added.

“China will try to keep the Taliban speaking, but there are unanswered questions about unity and the level of extremism in the new regime,” said Thomas.

Formal ties to Taliban in question

China has “laid the foundation” and prepared to work with the Taliban, but it is difficult to predict whether Beijing will officially recognize them as the Afghan government, CFR’s Johnson said, adding that western countries may not want anyone the Taliban confirmed.

“It can take a while,” he said. Beijing “may have wanted assurances that the Taliban would be a ‘normal government’ and not carry out … massacres and mass murders or anything like that before they were formally recognized by diplomatic means.”

If the Taliban behave “more or less normally,” China will likely recognize it “sometime” before Western countries, he added.

Grossman of the Rand Corporation reiterated this point of view, noting that China may think the time has come to begin the process of potentially recognizing the Taliban as a “legitimate entity”.

“But they have also said that they want to ensure that the Taliban make a ‘clean break’ with terrorist agents,” he said.

It is possible that China has asked its diplomats to stay in Afghanistan to … try to build trust and diplomatic influence with the upcoming Taliban regime.

According to a report by Reuters, the Taliban promised peace last week at their first press conference since the capture of Kabul.

In contrast to many other governments that want to evacuate embassy staff from Afghanistan, China’s ambassador will remain in Kabul for the time being. A spokesman for the Taliban’s political bureau reportedly said the group would not target diplomatic missions in the country.

It is wise for China to take this approach, which signals that Beijing is not afraid, takes sides, or is fleeing the Taliban, Johnson said.

That could also help in the medium term, says Thomas from Eurasia.

“It is possible that China has asked its diplomats to stay in Afghanistan to contrast with evacuations by Western missions and try to build trust and diplomatic clout with the upcoming Taliban regime,” he said.