The clashes started after several soldiers were air dropped into the Ab Kamari district of western Badghis province to conduct a night raid on Taliban hideouts and arrest a designate district governor of the hardline Islamist group.
Farid Akhizai, a provincial council member in Badghis, said the Taliban encircled the soldiers, killed 18 and captured 11. Ten were missing.
The district governor of Ab Kamari said a lack of coordination was to blame.
“The operation was conducted to raid a hideout used by several Taliban commanders, but the insurgents had evacuated the area two days before,” said Khudad, who goes by one name.
The Taliban in a statement confirmed that they had received a tip-off about the raid. They said their fighters killed 39 Afghan soldiers and captured 16.
The Taliban continue to stage major attacks against Afghan forces while they are engaged in a dialogue with the United States to negotiate an end to the 18-year long war.
President Ashraf Ghani said in January that more than 45,000 members of the security forces had been killed by militants since he took office in September 2014.