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.