The last British soldier left Afghanistan over the weekend. The last American combat troops will be gone by Christmas. Afghanistan’s beleaguered government is looking in new directions for help, and new President Ashraf Ghani arrived Tuesday in Beijing, where Chinese authorities are anxious to oblige.

If 2014 marks an endpoint for Western policy in Afghanistan, it is more of a starting point for China.

China will not send any troops to replace the departing NATO forces, local and foreign analysts agree. But Beijing, which offered Mr. Ghani hundreds of millions in aid Tuesday, is gearing up to play a leading role in Afghanistan’s future – fearful that if its neighbor descends into chaos, more trouble will spread into China’s restless, predominantly Muslim province of Xinjiang.

As terror attacks there grow more common, “the Chinese government cannot avoid facing this problem,” says Zhang Li, a South Asia expert at Sichuan University in the southwestern city of Chengdu. “Whether Afghanistan and Pakistan are stable is very important in this respect.”

Ghani, making Beijing his first official foreign destination since taking office last month, has good reason to put his hopes in China. China is one of Afghanistan’s biggest foreign investors; it has a reputation for neutrality and good relations with local political forces across the board. Beijing for its part has special influence with long time ally Pakistan, the key backer of the Taliban.

Certainly Ghani can go home with some tangible reassurance. He met with Chinese President Xi Jinping, who pledged the aid and told Ghani he will ask investors to look at development and natural resource industries like ore and mining.

(Last year one Chinese state company has already signed a $3 billion deal to develop a 5 million-ton copper deposit at Mes Aynak, near Kabul, but pulled its workers out last year after they came under Taliban fire.)

The Associated Press reports that China pledged $330 million in grants to Afghanistan through 2017, will provide professional training for 3,000 Afghans over the next five years, and also offered $5 million in humanitarian aid and will continue a scholarship program to 500 Afghans.

Most analysts say the West has no particular reason to mistrust Beijing’s effort to step up its involvement in Afghanistan, whose government is still fighting off a persistent insurgency by Taliban forces. China’s interest in a secure Afghanistan and a stable region matches US and European goals.

In July, China named a special envoy to Afghanistan, Sun Yuxi, a former ambassador to both Delhi and Kabul.

Significantly, during his three-day stay in Beijing, Ghani will attend a meeting of the Istanbul Ministerial Process, which China is hosting for the first time. The conclave is considered the most important in the region, attended by the US and EU, for mapping the future of Afghanistan and its neighbors.

Beijing’s host role for the meeting “is symbolic of their readiness to take on more responsibility for Afghanistan’s future than they have for the past 15 years,” says Andrew Small, an expert on China’s relationship with its Central Asian neighbors at the German Marshall Fund in Washington.

“China will be deepening its influence in this region as a coordinator,” agrees Professor Zhang, but it will not be rushing into anything. As Chinese diplomats familiarize themselves with the complexities of Afghan and regional politics “the most important thing for us to do at the moment is observe, so as to adopt the right policies,” Zhang says.

Ghani will also be touting Afghanistan’s plentiful mineral wealth to potential Chinese investors, who he hopes will bring prosperity to his war-wracked nation. But he knows that he will have to offer security to tempt them, since Chinese firms have been burned before.

In 2007 a Chinese state-run consortium made Afghanistan’s biggest ever investment – $3 billion in the Aynak copper mine – but the company pulled its workers out last year after they came under fire from Taliban guerrillas. The mining project has yet to yield a single ounce of ore.

“China intends to increase economic cooperation but we have learned some lessons,” says Zhang. “Signing the deals is the easy part.”

Ghani is banking on China to help restore the security that investors require, if not by military means then by diplomacy.

China has no interest in fighting in Afghanistan; Beijing would be reluctant to risk its working relations with all sides in the conflict.

But Beijing does have some sway over Pakistan, its long-time faithful ally, and Pakistan holds sway over the Taliban. Kabul is hoping that Beijing will put pressure on Islamabad to promote reconciliation in Afghanistan by encouraging the Taliban to negotiate with the government in good faith.

“China’s line has always been the same,” says Zhang. “It wants the Afghan government and the Taliban to reach a compromise and any effort to promote security will enjoy Chinese support.”

At one time, Chinese policymakers saw Afghanistan through a lens tinted by geopolitics, and they were wary of entanglement in a country that Beijing considered a protectorate of the West. Today, with NATO troops almost gone, that viewpoint has lost its currency. Instead, more immediate worries have loomed into the foreground.

Knife and bomb attacks by Xinjiang separatists in China's far-west province, whom the Chinese government believes have ties to foreign jihadi groups, have killed nearly 300 people this year in Xinjiang and in other Chinese cities.

Get the Monitor Stories you care about delivered to your inbox. By signing up, you agree to our Privacy Policy

Were the Taliban to reconquer Afghanistan, and spread their influence further into Pakistani border areas, Chinese officials fear this would fuel more terrorist violence in China.

“Nobody in Beijing is worried any more about a US presence (in Afghanistan) helping to contain China,” says Mr. Small. “It’s domestic security and the regional ramifications if things go wrong that is motivating them now.”