This is a complicated question and the reality is constantly changing:
To see links to all major Spanish mobile phone companies
Click here The info below might be out of date:
I have had extensive experience of Vodafone and Movistar.
Both companies are very bad and I could bore you with long horror stories.
Movistar are not as bad as vodafone.
With movistar you can eventually speak to a reasonable human being after hours of being passed around who will rectify the situation and maybe give you half the money back that they have ripped you off.
I unfortunately had to be signed up to vodafone because they were the only company with 3G in my area.
After a whole series of attrocious rip offs and terrible customer service the final straw was that they started charging me 15 euros a month extra for windows mobile profesional which I never solicited and could never even use because I use Android. After several faxes and hours on the phone I finally decided to get rid of vodafone. Of course they will ignore my attempts to end the contract and still try to keep charging me and in a couple of months the threatening letters and phone calls will begin again.
Vodafone have gone to such low depths of service that only a masochist wishing to be abused and humiliated would ever use them.
I have used Yoigo for a couple of years to get internet on my smartphone and have had no problem with them.
I would recommend that you go to a yoigo shop and get a pay as you go phone (pre-pago)
They currently have an offer of a simple phone with 5 euros of credit for 33 euros.
Their calling rates are good too.
https://yoigo.es/