At least 27 Taliban fighters were killed after they attempted an attack on Shirzad district in the eastern Nangarhar province on Friday evening, the provincial governor's office said in a statement on Saturday.
The militants had launched the attack near the district governor's office but were "pushed back and defeated," the statement clarified.
The attack started with two car bomb explosions and was followed by gunfight, the statement added.
The statement said that 32 other militants were wounded in the attack.
Two security forces lost their lives and eight others were wounded in the attack, the statement said.
Nangarhar Governor Shah Mahmood Miakhel praised security forces "bravery and high morale" in foiling the Taliban attack.
Miakhel said that in order to prevent civilian casualties they did not conduct airstrike and missile attack, but reinforcements were sent to the area when the attack started.
Taliban claimed responsibility for the attack.
This comes after the Taliban announced their spring offensive on Friday morning which is entitled Operation Al-Fatha - which means “victory” in Arabic.
The group said in a statement that the offensive will be conducted across Afghanistan with the aim of “eradicating occupation” and “cleansing our Muslim homeland from invasion and corruption”.
The announcement was widely condemned by the Afghan government, the United States and Afghan politicians.