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 harbouring 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 combatting 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.