Press TV reports.
The attack took place in the Karkh district of the Herat province late on Monday when two Afghan Army soldiers turned their weapons on Spanish troopers and injured at least three of them.
A local security official said on condition of anonymity that the Afghan soldiers belong to the 3rd brigade of the Afghan National Army in the province.
Taliban Spokesman Qari Yusuf Ahmadi, however, claimed that the Afghan soldiers joined the militant group and that they killed at least four foreign troopers in the attack.
Over the past months, there has been a rise in the so-called "green-on-blue" attacks in Afghanistan, in which Afghan security forces turn their weapons on US-led forces.
More than 61 US-led forces have been killed in "insider" attacks in Afghanistan in 2012, the highest since the US invaded the country in 2001.
The foreign troopers lost their lives in 45 "green-on-blue" attacks during the past 12 months.
The fatalities do not include an American adviser, who was killed by an Afghan female police on December 24.
A total of 35 US-led forces were shot dead by Afghan forces in 2011.
Growing "insider" attacks have created mistrust between Afghan and foreign forces.
The United States invaded Afghanistan in 2001 under the pretext of combating terrorism. The invasion removed the Taliban from power, but insecurity continues to rise across the country despite the presence of thousands of US-led soldiers.
Taliban say Afghan soldiers have opened fire on Spanish forces in the latest "insider" attack in the western part of war-torn Afghanistan,