The youth suddenly felt dizzy and took a dip in a swimming pool but suffered convulsions when he got out and collapsed, the regional government of Andalusia in southern Spain said.
Europe bracing for scorching heatwave
He was rushed to the emergency ward in the neighbouring town of Cordoba, where "he died after undergoing a cardiac massage", it said in a statement.
Spain is currently experiencing a heatwave of temperatures of 40 degrees Celsius and more across most of the country, which is expected to last until Saturday.
Three dead in Spain as Europe wilts under record heatwave
Out of a total 50 Spanish provinces, 34 have issued fire warnings, notably in Catalonia where fire services are fighting to put out a blaze that has already burned 16,000 acres of land.
Some 400 firefighters tackled the fire overnight, with planes and helicopters deployed in the morning to try and bring it under control.
The head of the Catalan interior ministry, Miquel Buch, advised the population to take "maximum precautions".
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ