Rural areas also have an abundance of older adults. In Teruel, the province in a remote corner of Aragon that contains Valderrobres, they make up a quarter of the population. Villages in the region, many with centuries-old ramparts overlooking the countryside, now have the appearance of boarded-up fortresses trying to keep their aged populations safe.

In other rural areas, such as the province of Soria, in the neighboring region of Castile and León, outbreaks overwhelmed for weeks the only hospital with intensive care units. Such rural stretches of Spain have among the lowest population density levels in Europe, and many there have long complained about being neglected and cut off by the national authorities.

In one village in Teruel, the only doctor in the area interrupted his weekly visits after he had to go into isolation; in another, the only grocery store closed for days after the shopkeeper left.

In Valderrobres, where the closest hospital with intensive care in the region is two hours away, the health authorities initially refused to test those at the nursing home who didn’t have symptoms, said the mayor, Carlos Boné, even as it became the epicenter of a local outbreak.

When Mr. Boné bought tests and discovered that two-thirds of the staff and residents had the virus, the regional authorities rejected the results because they came from a private lab, and then conducted their own tests a week later.