Afghan forces clashed with Taliban fighters in a provincial capital about 120 kilometres (75 miles) from Kabul, officials and witnesses said, prompting the defence minister to take charge of a counteroffensive.
Violence has soared in Afghanistan since US forces began their final pull-out on May 1, as the insurgents press on with a campaign to seize new territory.
Fierce fighting erupted late Sunday on the edge of Mihtarlam, a city of around 140,000 people and the capital of Laghman province.
At one point Defence Minister Yasin Zia took personal charge in the field, officials said.
"With the arrival of reinforcements, the enemy has sustained heavy blows," Zia, a former army chief of staff, said in a video message.
The ministry said at least 50 Taliban fighters were killed in overnight fighting.
Taliban spokesperson Zabihullah Mujahid told AFP the insurgents captured 37 security checkpoints on the outskirts of the city.
Casualty figures and battlefield gains can rarely be independently verified in Afghanistan and both sides frequently exaggerate their successes and minimise losses.
An AFP correspondent reported fighting continuing in some parts of Mihtarlam on Monday, adding that hundreds of people had been displaced.
A student from Mihtarlam, who gave just his first name Zabihullah, said he went to school after government forces assured him they had control, but had to flee when fighting resumed.
"I'm not sure which part of the city is safe now," he told AFP.
The attack on Mihtarlam comes as the Taliban push on in efforts to capture new territory.
In recent days the insurgents have seized the districts of Nerkh and Jalraiz in the province of Wardak, just 40 km from Kabul.
Wardak has long been used by militants as a gateway to reach the capital and launch deadly attacks.
The Taliban also captured Burka in northern Baghlan province earlier this month after government troops withdrew from the area.
The Taliban campaign has spurred speculation the militants are waiting for the Americans to complete their withdrawal before launching all-out assaults on Afghan cities.
The uptick in fighting around Kabul is stirring memories of Afghanistan's descent into civil war in the 1990s following the Soviet army's withdrawal, when militias choked off key routes into the capital and piled pressure on security forces until the government collapsed.
"The towns and cities the Taliban have targeted are of strategic importance given their proximity to Kabul as some are on supply roads to the capital," said Kabul-based security analyst Bari Arez.
"The setbacks suffered by Afghan forces also indicate that they had not expected such Taliban offensives so soon" after the US military started the final withdrawal, he added.