The incident took place near Farah in the west of the country, the Spanish defence ministry said on Saturday.
“The soldier Jorge Arnaldo Hernandez Seminario died after the explosion which happened as his vehicle was passing,” a ministry statement said.
The dead man had Peruvian nationality.
Two Canadian soldiers meanwhile were injured, one seriously, on Saturday in clashes with the Taliban near the southern city of Kandahar, Canadian officials said.
The two were hurt in separate incidents during battles some 30km west of Kandahar, in joint operations with the Afghan national army, a military spokeswoman said.
One of the soldiers was taken by helicopter to a hospital at the Kandahar airfield.
“He is in serious condition and is expected to be transferred to Landstuhl Regional Medical Centre in Germany for further treatment,” spokeswoman Holly Apostoliuk said.
The second Canadian soldier received a minor injury during battle.