Afghan troops have recaptured the centre of the strategic northern city of Kunduz after fierce clashes with Taliban militants, three days after losing the provincial capital in a humbling defeat for Kabul and its US allies.

But fighting continued in other parts of the city, whose brief capture represented a major victory for the insurgents and raised questions over whether Nato-trained Afghan forces were ready to go it alone now that most foreign combat troops have left.

Residents said soldiers were conducting house-to-house searches and had removed the Taliban flag from the central square, replacing it with government colours.

"There are military helicopters in the sky and government forces everywhere," said Abdul Ahad, a doctor in the city. "Dead Taliban are on the streets, but there are still (militants) in some government buildings fighting Afghan forces."

A Taliban spokesman denied the government had retaken all of Kunduz and said insurgent fighters had withdrawn to the edges of the city to avoid being encircled by Afghan and US forces.

Smoke was billowing from buildings on the city's outskirts.

"The Taliban are still resisting in the city," resident Wali Mohammed said.

Dawlat Waziri, spokesman for the Ministry of Defence, said the Taliban had left Kunduz city and a clearance operation was underway. A ministry statement said 150 Taliban had been killed and 90 wounded in the overnight offensive.

At least 30 people, mostly civilians, had been killed in the fighting as of Wednesday, according to a tweet from health ministry spokesman Wahidullah Mayar. He also said hospitals in Kunduz had treated about 340 injured.

Taliban spokesman Zabihullah Mujahid said fighting was continuing.

"It was our tactic to vacate the city to allow enemy troops enter so we could encircle them," he said.

A spokesman for the Western coalition did not comment directly on what role its troops played in the overnight offensive, if any, saying that they were "involved in Kunduz" in an advisory role.

The spokesman earlier confirmed a group of coalition special forces, including US troops, had engaged the Taliban in a ground clash.

There have been five US air strikes against Taliban positions near the city and airport since fighting broke out on Monday "to eliminate threats to coalition and Afghan forces".

The Taliban, who ruled Afghanistan with a harsh interpretation of Islamic law for five years, have been fighting to re-establish their Islamist rule after being toppled from power by a US-led intervention in 2001.

The once-quiet north of Afghanistan has seen escalating violence in recent years as the insurgency sought to gain territory, and swathes of Kunduz province have repeatedly come under siege this year.

Yet the Taliban's pre-dawn assault on Kunduz on Monday caught the Afghan police and army by surprise, handing the group arguably its largest victory in 14 years of war.

The three days it took to bring a major city back under government control may have political consequences for President Ashraf Ghani, whose first year in office has been clouded by infighting and escalating violence around the country.

The city's capture by the Taliban was a blow to the narrative that the Afghan police and army were steadily improving and able to prevent the Taliban from taking over and holding significant territory.