The Taliban claimed the Friday night attack, which Herat provincial governor spokesman Jilani Farhad told AFP killed 17 members of the Afghan security forces and wounded another.
There also were a number of Taliban casualties in the Zawol district ambush, Farhad said, but he could not provide exact figures.
Zawol district governor Mohammad Saeed Sarwari confirmed the attack and the death toll.
“The Taliban confiscated weapons following the attack,” Sarwari told AFP.
In a WhatsApp message, the Taliban put the death toll at 18 Afghan soldiers.
The attack came hours before the Taliban announced an unprecedented ceasefire with Afghan security forces for the first three days of Eid, the holiday that caps Ramadan.
That unexpected move came two days after the Afghan government’s own surprise announcement of an apparently unilateral week-long halt to operations against the Taliban.
It would last “from the 27th of Ramadan until the fifth day of Eid-al-Fitr”, President Ashraf Ghani tweeted from an official account, indicating the ceasefire could run from June 12-19.