I've tried to find a definitive answer before, more in regards to rock climbing / walking, but again later regarding exploring. It all seems a bit vague, but hey it's Spain.
From what I understand it's more or less the same as England and Wales, not really an issue unless you are on Government or Military property. If an owner catches you it's the usual verbal abuse, but he has the option to raise a Denuncia (a complaint to the police). The police will consider if any action needs to be taken. At worst they might come and talk to you. However the owner would have to get your details. I suppose if he saw you enter and then phoned the police rather than confronting you, you'd then talk to the police directly.
That's just my understanding of the law, and more than happy to find out differently.