The young man from the Andalusian town of Andújar suffered the fatal blow when he touched a high-voltage wire on a train he and his friends had assumed was not electrified.
They'd clambered on top of the parked wagon at Andújar train station to take a picture of themselves when they suffered the severe electric shock.
Spanish online daily Ideal reported that a 3,5000-volt discharge killed the young man as he went to take the photo.
Local paramedics and police rushed to the scene but found the 21-year-old was already dead.
One of his friends survived the shock but remains in a serious condition at the local Alto Guadalquivir Hospital.
Story continues below…
Andújar's mayor has declared three days of mourning for the town of 40,000 people in the middle of olive growing country.