Hundreds of militants were outside Sar-e-Pul city, which provincial governor spokesperson Zabihullah Amani said was at risk of falling to the Taliban if reinforcements were not sent.
The Taliban have stepped up attacks on security forces across the country, slaughtering police and soldiers in record numbers, as the threat of a US drawdown complicates American-led efforts to end the 17-year conflict.
"The enemy is still amassing forces outside the city," Amani told AFP.
"We have deployed all the forces available in the city, but no reinforcements have arrived from outside so far.
"The people inside the city are very worried."
Afghan Taliban says 'post-occupation' discussed with Iran
Taliban fighters launched the attacks on Sar-e-Pul and neighbouring Sayad district on Monday night, which Amani said were aimed at seizing control of several oil wells on the outskirts of the city.
At least 21 local forces, including police and intelligence, were killed and another 23 wounded in the attacks, Amani said.
"They have attacked the city many times in the past, but this time the threat is more serious," he said.
A security official, who spoke to AFP on the condition of anonymity, put the death toll slightly lower at between 15 and 20 members of local forces.
Kabul-based interior ministry deputy spokesperson Nasrat Rahimi confirmed there had been casualties, but would not provide details.
He said reinforcements had been deployed to Sar-e-Pul and dismissed concerns that the provincial capital was at risk of falling to the insurgents.
The Taliban confirmed the attacks, saying their fighters had captured three checkpoints and killed or wounded 50 members of the security forces.
Afghan Taliban were in Tehran for peace talks, says Iran
Afghanistan's largest militant group made significant territorial gains in 2018, including overrunning Ghazni city — a few hours' drive from Kabul — which they held for several days before being pushed back with the help of US airpower.
At the time, officials said Ghazni remained in government hands. But residents told AFP that the insurgents were in the streets, burning buildings and targeting civilians.
The Taliban's increased aggression on the battlefield coincided with a flurry of diplomatic efforts aimed at bringing the group to the negotiating table.
In recent days, Taliban representatives have met with Iran, as Tehran makes a more concerted and open push for peace ahead of a possible US drawdown.
The Taliban delegation discussed with Iran "the post-occupation situation, restoration of peace and security in Afghanistan and the region", the militants said in a statement posted on social media and emailed to journalists on Tuesday.
It signals growing confidence among the Taliban that US troops will pull out of Afghanistan, after US officials last month told various media outlets that President Donald Trump had decided to slash the number of boots on the ground.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ