Afghan commandos battled the Taliban for control of a provincial capital Thursday as the president insisted they had the capacity to defeat the insurgents even with a complete US troop withdrawal likely just days away.

Plumes of smoke billowed over Qala-i-Naw as fighting raged for a second straight day in the capital of Badghis province, with residents either fleeing the city or barricading themselves in their homes.

With the US pullout "90 percent complete" according to the Pentagon, the insurgents have launched a blistering campaign to capture new territory, and fears are mounting that Afghan forces will collapse without vital American air support.

President Ashraf Ghani said the government had the capacity to handle the situation, but admitted difficulties lay ahead.

A smoke plume rises from houses as clashes rage between Afghan security forces and Taliban fighters in the western city of Qala-i-Naw in Afghanistan A smoke plume rises from houses as clashes rage between Afghan security forces and Taliban fighters in the western city of Qala-i-Naw in Afghanistan Photo: AFP / -

"What we are witnessing is one of the most complicated stages of the transition," he said in a speech in Kabul.

"Legitimacy is ours; God is with us."

In London, Prime Minister Boris Johnson said most British troops had left Afghanistan, as part of a NATO withdrawal in parallel to the US pullout.

"I will not disclose the timetable of our departure, but I can tell the House that most of our personnel have already left," he said in a statement to MPs Thursday.

US President Joe Biden was due to speak on the US pullout later in the day after meeting his national security team.

The Afghan National Security Forces say the situation in Badghis province is "not to be worried about" after the Taliban launched a major assault on the provincial capital, the first since the US military began its final drawdown of troops from the countr The Afghan National Security Forces say the situation in Badghis province is "not to be worried about" after the Taliban launched a major assault on the provincial capital, the first since the US military began its final drawdown of troops from the country as insurgents press on with a blistering offensive in the north. Photo: AFPTV

The withdrawal of US and NATO troops -- after two decades in the country -- has drastically emboldened the Taliban, who appear to be pressing for a full military victory.

Supposed peace talks between the insurgents and the government in Doha have largely fizzled out after months of deadlock.

Video obtained by AFP showed thick smoke billowing over Qala-i-Naw Thursday, soundtracked by gunfire.

Badghis health official Abdul Latif Rostaee said at least 10 civilians had been taken to hospital since the fighting erupted.

Map showing parts of Afghanistan under government control and territories under the influence of the Taliban, from April till July. Map showing parts of Afghanistan under government control and territories under the influence of the Taliban, from April till July. Photo: AFP / Janis LATVELS

"The Taliban have resumed their attacks from several directions with light and heavy weapons," Badghis Governor Hessamuddin Shams told AFP on Thursday.

"Our security forces are bravely fighting them and the enemy is being pushed back. They are fleeing. We will give a hard blow to the enemy."

On Wednesday, the Taliban briefly seized the police headquarters and the local office of the country's spy agency, but were later pushed back.

Qala-i-Naw resident Aziz Tawakoli said Taliban fighters were still roaming the city, however.

"You can see them going up and down the streets on their motorcycles," he said.

Photo: AFP / Janis LATVELS

Tawakoli said many of the city's 75,000 people had fled their homes -- either to nearby districts or to neighbouring Herat province.

"The shops are closed and there is hardly anyone on the streets," he said, adding that helicopters and planes had bombed Taliban targets through the night.

Badghis provincial council member Zia Gul Habibi said the Taliban suffered casualties, but also surrounded the city.

"All districts are under their control... People are really in fear," she said.

"All shops and government institutions are closed. There are still reports of sporadic fighting."

Parisila Herawai, a rights activist in the city, expressed concern for the safety of women.

"It is an emergency situation for all women, especially activists," she told AFP.

"If the Taliban plan to remain in the city, we will not be able to work."

Local officials said some security officers had surrendered to the Taliban, and the insurgents opened the gates of the city jail, freeing hundreds of prisoners.

Most had since been recaptured, officials said.

Overnight, the defence ministry rushed hundreds of commandos to the city to launch a "large scale operation", spokesman Fawad Aman said on Twitter.

The attack on Qala-i-Naw comes as the Taliban carry out a blistering campaign across the country but mostly in the north, capturing dozens of districts since early May.

Rights group Human Rights Watch said the insurgents were forcing people from their houses in northern areas that they had captured.

"The Taliban's retaliatory attacks against civilians deemed to have supported the government are an ominous warning about the risk of future atrocities," said HRW associate director Patricia Gossman.

"The Taliban leadership has the power to stop these abuses by their forces but haven't shown that they are willing to do so."

Meanwhile a meeting between an Afghan government delegation and Taliban representatives in Tehran ended Thursday, Iran's state news agency said, with both sides urging an end to fighting, and more talks.