When firefighters arrived at the San Juan de la Peña monastery in northeastern Spain last Thursday, they faced a race against time. Flames were closing in on one of Spain's oldest and most sacred places, a monastery dating back to the 10th century that holds something irreplaceable: the bones of the first kings of Aragon.

Firefighters with Spain's army emergencies unit rushed into the ancient building as a wildfire bore down on the site, which legend also links to the Holy Grail. They grabbed transparent boxes filled with skulls and bones, artwork, and a chalice, hauling out everything they could carry in the final moments before the flames arrived.

"At the last minute, we were able to rescue assets of extraordinary historical value for this region and for all of Spain," said UME chief Javier Marcos. His unit stayed behind to defend both monasteries as the fire burned through the surrounding hills.

The San Juan de la Peña monastery sits perched in rugged mountain terrain in Aragon, close to one of the famous pilgrimage routes leading to Santiago de Compostela in northwestern Spain. Each year, around 100,000 visitors make the journey to see this living piece of Spanish history. Felix Longas, a member of a religious brotherhood that cares for the monastery, told RTVE that the site "has an incalculable symbolic value." He added, "It's our roots, our history lies there."

The monastery had prepared for this moment. Workers had wrapped the building's columns in fireproof material, and a shift in wind direction helped keep the flames away from the structure itself.

The fire has burned more than 10,000 hectares (24,000 acres) of land, roughly the size of a small city. Around 850 people were evacuated from nearby villages. Firefighters from France were being brought in to help the roughly 500 officers already battling the blaze.

Spain has been hit hard by wildfires this year. More than 283,000 hectares (699,000 acres) have already burned across the country, according to the European Forest Fire Information System. Last year was even worse, with nearly 400,000 hectares (988,000 acres) destroyed. The fires are made worse by heat waves linked to climate change. When firefighters arrived at the monastery, Aragon was under the second-highest orange warning for extreme heat, with temperatures reaching 37 degrees Celsius (99 degrees Fahrenheit).

Looking ahead, Longas said there was reason for cautious hope: forecasts predicted cooler temperatures and rain, which could finally help crews fully extinguish the fire. But Marcos said he remained nervous about how conditions might develop.

For now, the bones of Aragon's first kings are safe, and the centuries-old monastery still stands, waiting for pilgrims and history lovers to return.