Several cars were hit during the attempted escape, she said, adding that the truck had been stolen earlier in the day in a nearby district.
The man was being interrogated and a full investigation into the incident has begun, she said, adding that police were not ruling out any hypothesis.
Spain has kept its national security alert to one step below maximum since July 2015, following violent attacks in France and elsewhere.
In August 2016, as thousands of revellers packed a pedestrian esplanade in Nice to mark Bastille Day in France, a French-Tunisian man careened through the crowd in a deliberate attack, leaving almost 90 people dead.
French investigators say the attacker was inspired by ISIS propaganda on the internet, but had no links to the terror group.