More than 1,000 Afghan security personnel fled across the border into Tajikistan on Sunday following Taliban advances in northern Afghanistan, the Tajik border guard service said.

The crossings underscore a rapidly deteriorating situation in the country as foreign troops near a complete withdrawal after 20 years of war in Afghanistan.

Hundreds of Afghan security force members have fled swift Taliban advances in the north, but Sunday's retreats were the largest confirmed, coming just two days after the United States officially vacated its main base in Afghanistan as part of a plan to withdraw all foreign troops by Sep. 11.

The Taliban took over six key districts in the northern province of Badakshan, which borders both Tajikistan and China, following which 1,037 Afghan servicemen fled across the border with Tajikistan's permission, the border guard service said.

On Sunday, Afghan President Ashraf Ghani spoke to his Tajik counterpart, President Emomali Rakhmon, over the phone to discuss the developments.

‘Special attention was paid to the escalation of the situation in Afghanistan's northern areas adjacent to Tajikistan,’ a statement from the Tajik president's office said.

It added that Rakhmon expressed concern about the ‘forced crossings’ by the Afghan security force members.

A senior Afghan official confirmed there had been hundreds of crossings into Tajikistan but did not know the exact number. ‘The Taliban cut off all the roads and these people had nowhere to go but to cross the border,’ he told Reuters on Monday.

Last week, the United States vacated Bagram Airbase - bringing an effective end to the longest war in its history - as part of an understanding with the Taliban, against whom it has fought for two decades.

The Taliban has ceased attacks on Western forces, but continues to target Afghan government and security installations as it makes rapid territorial advances across the country.

Peace talks between the two sides remain inconclusive.

Related Story