The teenage girl was run over in by a train heading to Cartagena from Madrid, just outside of Alguazas station in Murcia, southeastern Spain.
The girl, who has not been named, failed to notice the oncoming train because she was wearing headphones and was "distracted by her phone" the mayor of Alguazas, Blas Ángel Ruipérez, explained to local media.
She was on her way to her dance class, on the other side of the tracks, when she was struck.
"We heard the train whistle two or three times and then we saw the girl lying on the ground," José and Carmen, siblings who were sitting in a nearby café, told local newspaper La Verdad.
The train driver blasted a warning signal but the girl failed to hear the noise because of the headphones she was wearing.
The accident happened at 4.41pm on Tuesday when the girl tried to cross the track just outside Alguazas station at a point where pedestrians are prohibited from crossing, sources from Spain’s train operator Renfe told Europa Press.
Firefighters were called to the scene but could nothing to save the girl.
The driver told police that he could not brake because "he was going at 140km/hour".
The girl was not carrying identification but police were able to identify her from her mobile phone and inform her parents of her death on Tuesday evening.
The town of Alguazas has declared three days of mourning for the girl, who came from a "well-loved family" in the town, according to Mayor Ruipérez.