The attack occurred in Shora Khak area of Kunduz Province on Sunday, the Afghan Defense Ministry said in a statement on Monday.
“Unfortunately, five army soldiers were martyred and three wounded,” said the statement.
In a post on Twitter, Taliban spokesman Zabihullah Mujahid, put the number of fatalities among the Afghan soldiers at 19.
According to Kunduz police, a fighting had been underway for several hours in the area.
A police spokesman, Enhamuddin Rahmani, said the militants also suffered casualties.
The attack came as the country is expecting a reduction in violence as negotiated between the US and the Taliban.
US Defense Secretary Mark Esper said on Saturday that Washington and the Taliban had agreed on a seven-day reduction in violence that could result in the exit of US troops from Afghanistan.
Esper, however, said the US has not yet fully set a date for when it will begin a period of reduction in violence negotiated with the Taliban.
A US official said on Friday that it would begin “really soon,” while the a Taliban official said it was imminent.
The two sides have been negotiating a peace deal on and off for a year in Qatar’s capital Doha.
US, Taliban negotiated proposal for 7-day reduction in violence: Pentagon chiefThe Pentagon chief says the United States and the Taliban have negotiated a proposal for a seven-day reduction in violence.
Talks restarted in Qatar last December, but were suspended again following an attack near the Bagram military base in Afghanistan, which is run by the US.
Violent assaults in Afghanistan have meanwhile been raging, with the number of clashes jumping to record levels in the last quarter of last year.
But in recent weeks, US special representative for Afghanistan Zalmay Khalilzad, who is leading negotiations with the Taliban, had launched a new round of shuttle diplomacy by traveling to Pakistan and Afghanistan to brief officials on the status of the talks.
A member of Taliban delegation in Doha told a local news agency on Monday that the talks had ended “successfully” with an agreement to be released before the end of the month.
The US invaded Afghanistan after the September 11, 2001 attacks. The invasion deposed the Taliban, but the group has never ceased its operations across Afghanistan, and has vowed to keep up its attacks until the withdrawal of all US forces.
Currently, there are some 13,000 US troops as well as thousands of other NATO personnel in Afghanistan.