BEIJING (Reuters) - China wants to have deeper military ties with Afghanistan, including counter-terrorism intelligence cooperation and joint drills, a senior Chinese officer told a visiting Afghan envoy.

Chief of the general staff of China's People's Liberation Army Fang Fenghui speaks during a press briefing with U.S. Joint Chiefs Chairman General Martin Dempsey (not pictured) at the Bayi Building in Beijing April 22, 2013. REUTERS/Andy Wong/Pool

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.

China wants to promote a regional counter-terrorism mechanism to “jointly protect regional peace, stability and development”, he added.

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 official Xinhua news agency said Atmar also met China’s domestic security chief Meng Jianzhu, where they discussed counter-terrorism too.

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.