China is quietly preparing for a more robust role in the future of Afghanistan, concerned that the withdrawal of Nato troops will leave a hotbed of militancy on its doorstep.
The two countries are connected by a narrow mountainous corridor that is almost impassable, which meant Beijing could focus on mining and mineral deals in Afghanistan as Western forces battled Taliban insurgents. But officials say that China is emerging as a key strategic player.
In August it will host a "Heart of Asia" conference on Afghanistan, which may have a newly elected president by then, inviting leaders from regional nations including India and Pakistan. A Western diplomat said China had already held discreet trilateral talks with Afghanistan and other countries.
One of its chief worries is that Uygur militants who want a separate state in western China's Xinjiang region will exploit the security vacuum left after the bulk of Nato forces withdraw by the end of the year to step up their fight.
The Afghan presidential hopeful, Abdullah Abdullah, who is leading a partial count of the first round of voting to replace Hamid Karzai, said he would work for the expansion of relations with China, describing China as a good neighbour of Afghanistan and a global power. "China has played constructive role in our reconstruction process and Chinese investments have been most welcomed in Afghanistan," Abdullah said.
Abdullah, a former foreign minister, said China and Afghanistan could explore further co-operation in dealing with terrorism, which he called a common threat. "As for China's position in the region, China has friendly relations with Pakistan, thus China can exert influence in promoting a better environment among countries in the region including between Afghanistan and Pakistan," Abdullah said.
Hundreds of Uygur fighters are believed to be holed up in rugged, lawless tribal areas straddling Afghanistan and Pakistan.
In a rare interview from an undisclosed location last month, their leader said China would be made to pay for its crackdown on separatists in Xinjiang.
"In the past we said: 'The Americans are there, and the Americans don't want anyone else, especially not another great power, taking their place'," said Hu Shisheng, a South Asia expert at a government-backed think tank, the China Institute of International Relations in Beijing.
"Now with the US strategic focus shifting, neighbouring countries cannot just let Afghanistan descend into chaos.
"The Pakistan and the Afghanistan Taliban are sympathetic towards the Uygurs. So we absolutely have to pay attention to this, in a way that perhaps we did not before," he said.
China has a US$700 million agreement to drill for oil in the Amu Darya Basin and a US$3 billion deal to develop the Aynak copper mining project. But insiders say security concerns, not investment, are the primary driver of China's new focus.
"They were focused on economics, not reconciliation or peace. But recently they have expressed their willingness to get more involved in the peace process," said a member of the High Peace Council, an Afghan government body overseeing negotiations with the Taliban. It is highly unlikely that China will follow the US lead and send soldiers.
Officials believe, however, that, with the West's attention on the region set to fade, Beijing has an opportunity to flex its diplomatic muscle, using warm relations with Afghanistan and Pakistan to ease suspicion between the two neighbours.
Afghanistan's deputy foreign minister, Ershad Ahmadi, said China had given assurances that it would encourage Pakistan to co-operate with Kabul's efforts to make peace with the Taliban. "We trust them. We are working on a plan," he said.
China's push for a bigger role in Afghanistan is seen by some diplomats as an attempt to show it is a responsible global actor after rattling its own neighbours by asserting claims in the South China Sea.
But Andrew Small, a fellow at the German Marshall Fund and author of an upcoming book on Chinese-Pakistan relations, said it was driven by a realisation that its own security is at stake.
"At the end of 2011, the Chinese realised America was leaving and they were getting this dumped on their lap," he said. "Until then, China had sat completely on the sidelines. They just used to send people to read out statements in meetings."
Additional reporting by Xinhua