The overwhelming wealth of cathedrals, churches and other religious institutions throughout Spain gives the visitor a pretty clear idea about religion in Spain. Roman Catholicism is the clear frontrunner in Spain's religious scene, with polls placing the percentage of self-identifying Catholics at anywhere between 81% and 94% of the population. Due to this high percentage, you can more or less look at Catholicism in Spain as more of a cultural aspect than a religious one. People, even if they've never attended church services in their life, almost automatically identify themselves as Catholics because - as a Spaniard - it's practically a given.
However, Spain's views on major social issues are much more liberal than in other European countries- perhaps due to the repressive, 35-year dictatorship that came to an end just a few decades ago. There is a widespread support - over 70% in favor - for gay marriage and, in 2005, a bill was passed to legalize it. Spain also has liberal views and laws regarding adoption for gay couples, abortion, birth control and divorce- all of which goes pretty directly against the ideas of the Catholic church.
This religious uniformity has strong ties to the Spanish Inquisition, a rather dark period of Spain's history that essentially plunged Spain into a 350-year hunt - through rather unpleasant means - for pretty much anybody who disagreed with the principles of the Catholic church. The country, which historically had significant populations of Jews and Muslims, saw its Catholic percentage hit 100% after forcing the persecution, conversion, expulsion and even execution of these communities, particularly during the 15th and 16th centuries.
In recent years, the immigration wave has ushered in a rising population of practicing Muslims after a centuries-long absence. There are now over one-million Muslims in Spain, along with small but present populations of Jews and various Protestant denominations.