A local security official speaking on the condition of anonymity said, the two Afghan army officers belong to the 3rd brigade of the Afghan national army in Herat province.
He said Spanish troops did not suffer any casualties however the two Afghan officers managed to flee the area and the two will possibly have links with the Taliban group.
Herat is relatively a peaceful province in western Afghanistan and this is the first insider attack by Afghan army on their international counterpart in this province.
In the meantime eye witnesses in the area said at least three Spanish troops were injured following the attack who were taken to ISAF military hospital but coalition officials said no ISAF soldier was injured following the incident.
A spokesman for the Taliban group claimed responsibility behind the attack and said it was carried by their fighters, killing at least 4 Spanish troops.
Insider killings by uniformed Afghans against their foreign allies rose dramatically in 2012, eroding confidence between the sides at a crucial turning point in the war and when NATO troops and Afghan counterparts are in more intimate contact.
Spain has deployed around 2,000 troops under the NATO-led International Security Assistance Force mission in Afghanistan. They are based in western Badghis province.