At least two Spanish soldiers have been killed and three others injured after a suicide attacker crashed an explosive-laden vehicle into their convoy, an ISAF spokesperson said.
The Taliban claimed it carried out the attack on Sunday in the town of Azizabad in northwestern Herat province.
"Two Spanish soldiers were killed and another was critically wounded in an attack south of Herat," a Spanish defence ministry spokesman said.
General Ikramudin Yawar, an Afghan police commander, said the troops were attacked in the Shindand district as they were travelling in a convoy with Afghan soldiers.
Earlier reports had said the dead and injured were Italian soldiers in the Nato-led International Security Assistance Force.
"This is usually a non-combat zone but this time according to the Afghan national police, there were RPGs, rocket fire and a suicide bomber. Isaf police have told us that things are very sketchy," Al Jazeera's David Chater, reporting from the capital Kabul, said.
"Earlier this month, we do know that a suicide bomber was picked up in this area ... so things are developing in the Herat area."
An Afghan commander told Al Jazeera that the attack had been carried out in response to an incident in August in which at least 90 civilians, mostly women and children, were reportedly killed in a US raid.
Violence has increased steadily in Afghanistan in recent months as the Taliban, who were in government between 1996 and 2001, have grown in strength.
Spain has about 700 military personnel based in Afghanistan, most of them in Herat province.
The latest attack brings the number of Spanish troops killed in the fight against the Taliban to 25, while the total number of foreign military deaths in Afghanistan since the Taliban government was toppled is more than 1,000 soldiers.