Image copyright AFP Image caption It is hoped the hotline will reduce tensions on the Afghanistan-Pakistan border

Pakistan and Afghanistan have established a hotline between their respective military commanders to reduce frequent cross-border tensions.

Pakistan's military spokesman says the line has just been used for the first time as the two countries work to improve co-ordination along the border.

The move was agreed when Pakistani army chief Raheel Sharif visited Kabul.

Security co-operation between the two countries is seen as crucial in countering the growing Taliban threat.

Earlier this month Afghan President Ashraf Ghani blamed Pakistan-based militant groups for the escalating violence.

Image copyright AP Image caption Afghanistan accuses Pakistan of secretly controlling the Afghan Taliban

Afghan officials often accuse Pakistan of controlling the Afghan Taliban.

The say that Islamabad allows the most senior Afghan Taliban leaders to operate freely there. Pakistan denies this although it admits having contacts with the militants.

News of the hotline comes as Afghanistan will host discussions next week with Pakistan, the US and China to prepare the ground for possible Afghan peace talks involving the Taliban.

Afghanistan sees Pakistani support as crucial if negotiations with the Taliban are to be successful.

President Ghani has recently moved towards strengthening ties with Pakistan - the Taliban's historic supporters - in what correspondents say is a desperate bid to restart peace negotiations as the insurgency spreads.

The president warned that the presence of international militant groups - including al-Qaeda, Islamic State and militant groups from China, Russia, Uzbekistan, Tajikistan and the Middle East - was growing in Afghanistan.

Pakistani Prime Minister Nawaz Sharif said at the beginning of this month that "working for the achievement of a peaceful neighbourhood is a cardinal principal of Pakistan's foreign policy".

"We should envisage collective and co-ordinated measures on the regional security front to ensure that the gains and struggle against terrorism are durable and irreversible," he said.