Despite some Internet sources claiming that prostitution is legal in Spain, the truth is that sex workers exist in a legal vacuum. The workers themselves are not penalized, but instead, the procurers are the ones who are punished by the law. And for good reason, as 90% of sex workers in Spain are said to be victims of human trafficking which can get quite complicated legally.
Brothels have been illegal in Spain since 1956, but these days, the vast majority of them are loosely disguised as whiskerías or "clubs" and are left to function as normal.
But these clubs aren't the only legal loophole in the Spanish system. Sex workers have been able to practice their trade freely and advertise frequently in the "Relax" section of the classifieds in newspapers and magazines. However, a proposal suggested that all contact sections of newspapers should be closed down to prevent the advertising of prostitution. While this may not end the problem at the source, the Spanish Government sees it as one way to curb the demand for sex work in larger cities.
What is totally illegal is public solicitation for sex, i.e. "street prostitution". Both the sex worker and his or her client can be prosecuted in some parts of Spain, including Barcelona.
Truthfully, prostitution in Spain doesn't have the stigma that it has in many other countries. You can often come across sex workers in open, public spaces such as Gran Via in Madrid and Las Ramblas in Barcelona, so to many it may seem like a completely typical aspect of life in a large Spanish city.
But don't be fooled by the pretense of acceptability. Prostitution in Spain is not the regulated wholesome affair that it is in, say, the Netherlands. Human trafficking is a very serious, global issue, and hiring exploited sex workers directly funds some tremendously nefarious activity. Spanish organizations like Mujer Emancipada and Colectivo Cominando Fornteras are working to end human sex trafficking in Spain, a country that often grapples with migrant rights.
To learn more about human trafficking in Europe, you can visit ENPATES, a multi-nation coalition currently tackling the problem.
Like all countries, Spain has its own laws and cultural signifiers that make visiting or living there unique. Read up on the legality of cannabis and nudism as well, and make sure you always have all the facts when traveling abroad. Stay safe!