A passerby discovered the girl in a distressed state inside the car with the windows closed and the doors locked and called police.
Officers had to break a window to rescue the child, who was sweating profusely and suffering dehydration, according to a statement from the Policia National.
The parents arrived back at the car after a two and a half hour shopping spree to discover their daughter being taken away in an ambulance. And they were promptly arrested.
The pair are now facing charges of child neglect.
Ten cabeza y sé responsable: detenidos en Marbella padres que dejaron a su hija d 12 años encerrada en el coche al sol 2 horas, deshidratada— Policía Nacional (@policia) July 30, 2015
"Keep your head and be responsible," warned a police message on twitter. "Parents arrested in Marbella for leaving their 12 year old daughter locked in a car in the sun for two hours, dehydrated."
Police and animal charities regularly warn of the danger of leaving dogs locked in cars during the summer months.