There is no passport control but theoretically everyone should be able to demonstrate that they are in Spain legally.
If a citizen of an EU country that means valid identification. I'm not aware of anything else but I'm sure someone will enlighten me if I'm wrong.
If not a citizen of an EU country that that means a valid EU or country specific visa and the means to comply with the visa requirements.
In my case a tourist visa is automatic on entering the EU, but I need a passport (with expiry date more than 6 months after my expected exit), transport out of the country within 90 days, and the financial means to support myself during the time I will be in Spain.