I'm pretty sure that this is Ceratopogonidae, close to Dasyhelea, due to the long spiracles. However, I'm not familiar with Spanish species, so genus level is not sure.
Thank you both. Unfortunately, I do not know which region of Spain or habitat it was taken from. It was sent to me. I'm not accustomed to looking at European taxa (only UK). Ceratopogonidae looks promising. (It is ~2 mm).