The couple were dining on a terraza in the centre of Pizarra when they lost sight of the daughter, who was playing nearby.
A team of more than 600 people frantically searched for the child after parents raised the alarm at 11.20pm on Wednesday night.
Authorities, including police, firefighters and civil protection units and dozens of volunteers, searched into the night in the town northwest of Malaga where the family were resident.
— Guardia Civil (@guardiacivil) July 27, 2017
Felix Lozano, the mayor of Pizarra, said the parents raised the alarm after “they lost sight of the daughter for two minutes”.
The little girl’s body was eventually discovered at 7am this morning lying lifeless alongside a railway track some seven kilometres from the restaurant.
A train driver spotted what he thought could be a body and stopped the train to alert authorities, according to a report in the local Diario Sur.
The Civil Guard have opened an investigation into the circumstances of her death.