Though a long way from the very public red light district of Amsterdam, Madrid's sex district is so central and interwoven into normal Madrid that it's a good thing that Madrid's sex district is safe - if it wasn't, a lot of Madrid's most important streets would be off limits!
However, there is a second area of town, the Casa de Campo park to the west of the city, where prostitutes tend to congregate.
The atmosphere here is more unsavory and best avoided.
Red Light District in Madrid
Madrid's sex district is little more than a large number of sex shops, invariably with 'cabins' to watch pornography and some with peep shows. A few also offer contact with the 'models'.
The biggest such sex shops are on Calle Atocha, the street that connects the main Atocha train station with the center. One of them also has a museum of erotic art.
The other main areas where you will find such shops are on c/Montera (between Puerta del Sol and Gran Via) and in the streets immediately north of Gran Via. Not long ago, there was even a sex shop on Gran Via itself. But the whole area is cleaning up, with Montera now pedestrianized and a casino at the top of the street.
The only area we would recommend keeping away from (at night, at least) is c/Luna, a large plaza/street just north of Gran Via. The streets around here have a number of sex shops and at night attract prostitutes, but in the daytime, there are restaurants and people around, making it a safe place to be.
Prostitutes congregate around this area north of Gran Via, as well as on the aforementioned c/Montera. They are known to hassle men, making distinctly unattractive clucking noises (I've no idea on what planet that is considered sexy) and at times grabbing hold of men. Montera at night is when there are the most prostitutes on the streets and so is probably best avoided.
However, apart from the fact that it is aesthetically displeasing, trouble rarely occurs. Women in particular, as long as they keep walking, should not have anything to fear - it is obvious which girls are the prostitutes, so neither the sex workers nor their clients are likely to pay you any attention. Men should be more wary, as the amorous attention that the girls 'lavish' on you is often accompanied with stray hands that might find their way onto your wallet.