If you are in Spain (no matter what country you are from), you must carry a valid ID card or passport at all times, and failure to do so could see the police detain you temporarily whilst they ascertain your identity, and furthermore, it is within their rights to issue a fine.