When the Taliban took over Afghanistan the first time in 1996, China refused to recognize their rule and left its embassy shut for years. This time around, Beijing has been among the first to embrace the Islamist terrorists next door.
China's remarkable shift was on display little more than two weeks ago, when Foreign Minister Wang Yi welcomed a Taliban delegation to the northern port of Tianjin as the group made gains against the administration of President Ashraf Ghani, who fled the country on Sunday. Wang's endorsement of the Taliban's "important role" in governing Afghanistan provided a crucial boost of legitimacy for an organization that has long been a global pariah due to its support of terrorism and the repression of women.
China's reasons have as much to do with its own rise as a global power as the Taliban's surprisingly swift march on the Afghan capital. China today commands an economy worth $14.7 trillion -- more than 17 times its size in 1996 -- and a massive trade-and-infrastructure initiative that stretches across the Eurasian landmass.
Beijing's fears about Islamist extremism among its own Uyghur minority have also deepened in recent years, leading it to build a vast police state adjacent to Afghanistan. Moreover, an increasingly intense rivalry with the US has prompted Chinese President Xi Jinping to seize any opportunity to push back against Washington's dominance and push American forces away from his borders.
Those interests make China look like the next great power with a stake in bringing order to Afghanistan as the Taliban prepare to declare an Islamic emirate in Kabul. After the failures of the Soviet Union and now the US, China will be hard pressed to avoid repeating the same mistakes in a rugged and landlocked nation notorious for exhausting empires.
"Twenty years ago, China wasn't a global power and what was happening in Afghanistan didn't bother China,” said Yun Sun, director of the China Program at the Washington-based Stimson Center. “But today, there are so many new factors -- there's the Uyghur issue, there's economic interests and China's self-perception as a global power.”
China has sought to portray itself as more pragmatic and less interventionist than the West while urging a negotiated peace. “China hopes the Afghan Taliban can unite with other political parties and with all ethnic groups and build a political framework in keeping with national conditions that is broadly inclusive and will lay the foundation for enduring peace,” Foreign Ministry spokeswoman Hua Chunying told reporters Monday in Beijing.
Still, Hua stopped short of endorsing the Taliban's rule, saying only that the situation in Afghanistan had "experienced major changes."
It was all part of a long evolution by China, which once denied any connection with the Taliban before hosting the first delegations from the group in 2013. Now, as Taliban fighters made their entrance into Kabul, posts circulated on China's heavily censored social media comparing the event to Mao Zedong's taking of Beijing in 1949.
Meanwhile, state media gloated over the American withdrawal, with a commentary in the official Xinhua News Agency declaring it the "death knell for declining US hegemony."
"The sound of roaring planes and the hastily retreating crowds mirrored the last twilight of the empire," the piece said.
Even so, China is one of the few countries that saw some benefit from the US's $840 billion nation-building debacle, which bogged down Beijing's rivals while creating a relatively stable environment for its companies. That's left China with economic interests to secure, including a copper mine and several oil blocks. The country evacuated some 200 business people last month.
Afghanistan's stability is key to protecting more than $50 billion worth of Belt-and-Road projects in neighboring Pakistan that provide a crucial overland route to and from the Indian Ocean. But perhaps no issue is as pressing for Beijing as ensuring that Afghanistan doesn't become a source of extremism that bleeds over the Chinese border.
Wang, the Chinese foreign minister, pressed chief Taliban negotiator Mullah Abdul Ghani Baradar during their July 28 meeting to make a "clean break" with the East Turkestan Islamic Movement. China blames the group for terrorist attacks it has cited to justify crackdowns in the Xinjiang region that the US and others say amount to genocide.
Baradar pledged that the Taliban would never allow any force to use Afghan territory to engage in acts detrimental to China, according to the Chinese statement.
"China's attitude toward a Taliban-led regime will depend on its policies, for instance, whether the Taliban will honor its promises and not to become a hotbed for extreme forces that have links to China," said Fan Hongda, a professor at the Middle East Studies Institute of Shanghai International Studies University.
Afghanistan could become the biggest test yet of a Chinese diplomatic model that's driven by loans, commodities and infrastructure deals rather than demands for liberal policies. If the Taliban pursue moderate policies toward women that don't alienate other nations, and achieves political stability, Beijing might consider an array of investments similar to what it has done in Pakistan, according to Sun, of the Stimson Center.
"The Chinese approach is, 'Through economic infusion we create roads, we create infrastructure, and we make sure everyone has jobs,'" she said. "And if everyone goes to work at nine in the morning and comes home at 6 pm, they don't have time to think about terrorism."
Track Latest News Live on NDTV.com and get news updates from India and around the world