A long-distance train passing through the station in Castelldefels hit a group of people crossing the tracks who had just gotten off of a commuter train. The group crossed over the tracks above ground rather than using a designated tunnel underneath, the official with the Catalonia regional government said.
Emergency services found dismembered bodies scattered at the scene of the accident at Castelldefels Playa station, El Pais newspaper reported.
The group apparently got off a train and then tried to cross the track to head for the beach, local radio quoted emergency services as saying.
Spanish radio station Cadena Ser said most of the fatalities and injuries were young people who had arrived in the town to celebrate a festival marking the start of summer.