The unusual decision is just one of several measures taken in recent days as the country goes through a heatwave with temperatures soaring above 40C (104 degrees Fahrenheit) in some places including the Spanish capital.
A spokesman for emergency services in the region told AFP that dozens of “students aged 12 to 18 were transferred to a place close to their school, an air-conditioned funeral home” in Valdemoro near Madrid on Thursday.
The reason? Extreme heat.
“Five students had been taken to hospital, one for heatstroke, the others because they were nervous” due to the heat, the spokesman said.
The school year in Spain ends before the end of June – earlier than in other European countries – due to the summer heat.
But with temperatures hitting record highs, controversy is growing over public schools' lack of readiness for scorching heat, hit as they were by spending cuts during the financial crisis.
The Feuso education union has asked that class ends at midday on days of heatwave, when it says school buildings turn into “saunas.”
Madrid's regional authorities, meanwhile, have allowed establishments to “shorten school days.”
And Jesus Sanchez Martos, a doctor in charge of health issues at the Madrid regional government, suggested students make their own paper fans – a proposal that earned him much criticism.
But it's not just the notoriously roasting Madrid region that is suffering.
In Murcia in the southeast, Antonio Leon, mayor of the town of Torre Pacheco, has called for school buildings themselves to be better conceived.
“Yesterday, a three-year-old suffered from heat stroke and emergency doctors were called in,” he told AFP.
He said the temperature had reached 33.3C in the classroom, in a concrete building.
By law, the temperature in classrooms should be between 17C and 27C, according to the Feuso union.
Leon said air conditioning was the obvious answer, but “another cheaper solution would be to put up awnings that would protect from the radiation of the sun.”
On Friday, Spain's Energy Minister Alvaro Nadal promised to implement a programme to “better insulate” public schools.