A barn in the small Cantabrian village of Setién caught on fire after bales of hay inside "spontaneously combusted" due to high temperatures, endangering the cows inside, local newspaper El Diario Montañés reported.
But the owners of the farm were able to corral the cattle safely out of the barn before firefighters arrived to douse the flames.
Regional councillor and town resident Daniel Fernández told El Diario Montañés that all evidence indicated the fire had been caused by the high temperatures.
Spain along with many other parts of western Europe are on alert over a heatwave, with temperatures reaching as high as 44C (111 degrees Fahrenheit).
The Spanish national weather office warned on Monday that the risk of forest fires was "very high" in some places.