Officials in Afghanistan have recaptured government buildings in a city which was attacked by the Taliban, according to Reuters.
On Wednesday, the Taliban entered Qala-e-Naw, the first direct attack on a provincial capital since Washington began pulling out its last troops.
Air strikes were used and special forces deployed to push the fighters back, Reuters said.
The Taliban has been making gains as the US and allies pull out.
“The enemy suffered heavy casualties and now we are advancing and driving the enemy out,” special forces commander Sayed Nezami said, according to Reuters.
A spokesperson from the Ministry of Interior Affairs claimed said the city in the north of the country had been cleared of Taliban fighters and that it was now fully under the control of Afghan security forces, according to a report by the Khaama Press News Agency.
A news report by Tolo also quoted the city’s provincial governor as saying that the Taliban had been “pushed back from several parts of the city”.
The vast majority of remaining foreign forces in Afghanistan have left ahead of an 11 September deadline, leaving the Afghan military completely in charge of national security.
‘Driving the enemy out’
On Wednesday, Taliban troops had briefly entered the city.
Local sources told the BBC the Taliban gained access to the city’s prison and freed about 400 inmates, including more than 100 of its own fighters.
Afghan forces guarding the prison were reported to have surrendered without a fight.
At the time, Governor Hisamudin Shams said the headquarters of the intelligence service had been set on fire.
But he denied reports the city had fallen to the Taliban, and said Afghan troops were defending it. The governor told Reuters the militants attacked the city from three directions in the morning.
Security forces later carried out air strikes to clear militants from Qala-e-Naw, in north western Badghis province, officials said, and special forces were used to remove insurgents from the government buildings they had briefly occupied.
The Taliban have seized dozens of districts in recent weeks and are now thought to control about a third of the country, making new gains on a daily basis. So far provincial capitals have remained under government control.
Under a deal with the Taliban, the US and its Nato allies agreed to withdraw all troops in return for a commitment by the militants that they will prevent extremist groups from operating in areas they control.
But the Taliban did not agree to stop fighting Afghan forces, whose ability to hold off the insurgents is being questioned.
Military officials in Kabul have talked about “tactical retreat” whenever insurgents make gains, but commanders in the battlefield have told the BBC about a lack of ammunition, and delays in sending support.
Fleeing Afghan troops
Neighbouring countries are bracing themselves for a potential influx of refugees if the fighting continues to intensify.
The foreign minister of Iran, which shares a border with Afghanistan, said the US had failed in Afghanistan and its presence had caused major damage to the country. Mohammad Javad Zarif was speaking in Tehran during a meeting between an Afghan delegation and representatives of the Taliban.
President Ashraf Ghani insists that Afghan security forces are fully capable of keeping insurgents at bay, but more than 1,000 Afghan troops have fled over the border to Tajikistan in recent days, and there have also been reports of more soldiers seeking refuge in Pakistan and Uzbekistan to escape the fighting.
Earlier in the week, Taliban spokesman Suhail Shaheen told the BBC that the group was not responsible for the recent increase in violence. He insisted that many districts had fallen to the Taliban through mediation after Afghan soldiers refused to fight.
For the people of Afghanistan, it is a worrying time. The Taliban, who have been accused of various human rights and cultural abuses, support punishments such as public executions of convicted murderers – as well as banning television, music and cinema, and disapproving of girls over 10 going to school.
US-led forces ousted the Taliban from power in Afghanistan in 2001. The group had been harbouring Osama Bin Laden and other al-Qaeda figures linked to the 9/11 attacks in the US that triggered the invasion. However, it has gradually been regaining territory in recent years.
The Taliban entered direct talks with the US in 2018, and President Joe Biden has said the American pull-out is justified as US forces have made sure Afghanistan cannot become a base for foreign jihadists to plot against the West again.
Many observers question that claim.
On Tuesday it was reported that the US military left Bagram Airfield – its key base in Afghanistan – at night without notifying the Afghans.
Click here to see the BBC interactive