The Ley de Costas (coastal law), passed in 1988, set out to protect the shore by turning all beaches into public land and prohibiting the building of new residential zones within 100 metres of them. The problem is that urban-planning rules in Spain have often been ignored, and so, over the years, thousands of residential properties have been illegally built close to the beach, often with permission from local authorities.
This is not relevant to older buildings (pre 1988) However, exactly where you start measuring from does seem to be open to debate.
The EU Auken Report highlights problems of the Ley de la Costas for property owners in Spain:
See: Spanish property insight, April 2009
For more on the Ley de la Costas see:
Ley de Costas - Spanish Property Insight
Note: The law as described in this article has since been modified
Spanish Government has added a last minute amendment to the Ley de Costas, Coastal Law. The change comes as an attempt to lessen the barrage of criticism the law has received from Europe, following complaints from the British and German embassies.
The 1988 law declares that the beach is public land, up to the point where the sea reaches in the worst of storms. Any homes built in that area before 1988 were taken into ownership by the state ahead of demolition, but the owners were granted up to 60 years grace, but they were told that they could not sell or reform their properties. The decision on whether a particular property lies in the public area was allowed to take five years. The reform has now come via an amendment to the Maritime Navigation law, taking the legislation change directly via the Justice department and away from the Environment Ministry, needing only additional approval in Congress.
It states that such property can now be bought and sold, and indeed passed in inheritance, provided the building was built legally before 1988. An estimated 45,000 homes are estimated to be affected all along the coasts of Spain.