China is working with Pakistan and the United States to broker peace talks to end a Taliban insurgency that has raged for 15 years in Afghanistan, but last month the militants refused to take part.

The U.S.-led NATO mission ceased combat operations at the end of 2014, and has withdrawn most of its forces. China says it does not seek to fill a void left by their withdrawal.

But, it has promised to play a "huge" commercial role in helping rebuild the country, where the Taliban seek to re-establish their Islamist regime.

China is very nervous at the prospect Islamist militants from its restive far western region of Xinjiang getting support from the Taliban and other groups in Afghanistan, Pakistan and central Asia.

Fang Fenghui, a member of the powerful Central Military Commission which controls China's armed forces, told Mohammad Hanif Atmar, the Afghan president's national security advisor that their two armed forces had always had good relations, China's Defence Ministry said late on Wednesday.

China is willing to "deepen counter-terrorism intelligence, joint drills, personnel training and other areas of practical cooperation", the ministry cited Fang as saying.

Relations between Afghanistan and Pakistan, which prizes its long-time alliance with China, have been fraught with mistrust in the past.

For year, Afghan leaders repeatedly accused Pakistan of harboring Taliban militants and covertly supporting their cohorts. But, the Taliban's recent refusal to join a peace process and ongoing offensive has raised doubts over how much influence Islamabad still exerts over the militants.

Atmar told Fang Afghanistan was willing to work with China to fight terrorism, and explained the Afghan role in combating the East Turkestan Islamic Movement, which Beijing blames for much of the violence in Xinjiang, the ministry said.

China's vice president last year pledged infrastructure and security support for Afghanistan, signing several deals during a rare high-level Chinese visit to Kabul.

China has become increasingly concerned about what it calls extremists and separatists Xinjiang, where violence has killed hundreds in recent years, and sees security in Afghanistan as key to stability at home.

Rights groups, however, blame unrest in Xinjiang on the frustration of the largely Muslim Uighur people from the region over China's controls on their culture and religion, charges Beijing denies.