The seizure of Nerkh district comes amid intensifying violence following an announcement by the group of a three-day ceasefire in Afghanistan for the Muslim religious holiday of Eid, starting this week.
Afghan security forces have mounted an operation to recapture a Taliban-held district outside the capital Kabul just before the start of a three-day ceasefire at midnight, according to a local official.
Taliban insurgents had killed or captured some government soldiers and forced others to retreat after storming the district centre, which lies in Wardak province less than an hour's drive from Kabul.
Government forces have been struggling against stepped-up attacks by the insurgents as US troops withdraw after two decades of fighting in the country.
Wardak mayor Zarifa Ghafari said that if the district was not taken soon, fighting would reach the gates of Kabul in a few days.
The defence ministry said on Wednesday special forces have been deployed in the area to retake the district after troops made a "tactical retreat" on Tuesday.
A senior government official said they aimed to regain control before a three-day ceasefire announced by the Taliban for the Muslim religious holiday of Eid, which starts on Thursday.
"We will have to do it today because after the ceasefire, it will give the Taliban enough time to dig in and will complicate the operations and increase our casualties," the official said, speaking on condition of anonymity.
The government carried out air strikes at the start of the operation, the defence ministry said.
Launchpad for attacks on Kabul
The insurgents have maintained a strong presence in Wardak and nearby Logar province to the south over the years.
Afghan officials say the Taliban have used the provinces as launchpads for hit-and-run attacks and suicide bombings on Kabul.
The Taliban has staged a months-long campaign to expand its influence across the country as the United States has begun withdrawing troops from May 1 and closed some bases in keeping with a peace deal it signed with the Taliban last year.
Afghan officials say since Washington announced plans last month to pull out all US troops by September 11, the Taliban have stepped up attacks.
Critics of the decision to withdraw say the militants will try to sweep back into power.
US-led forces ousted the Taliban from power in late 2001 for sheltering the Al Qaeda militants involved in the September 11 attacks on the United States.
10 percent of US withdrawal completed
Large swathes of Wardak and neighbouring Logar province have been controlled or contested for years by Taliban fighters and have served as a strategic staging ground for militants hoping to enter Kabul.
Taliban fighters have been increasingly encircling major Afghan urban centres, spurring speculation the militants are waiting for the Americans to withdraw before launching all-out assaults on the country's cities.
The US on Tuesday said the Afghanistan withdrawal was up to 12 percent ahead of deadline.
The military gave an approximate range of between 6 to 12 percent completion as of May 10, noting the equivalent of 104 C-17 cargo aircraft worth of equipment has been removed from the war-torn country, and 1,800 other pieces of equipment have been destroyed.
US President Joe Biden set a September 11 deadline for all US forces to be withdrawn from Afghanistan, bringing a close to a 20-year war that has cost Washington roughly $2.2 trillion and resulted in about 2,400 military deaths, according to the Costs of War Project at Brown University.