ARCHIDONA, Spain — When the Spanish authorities intercepted about 500 Algerian migrants who had traveled by boat to the southeastern coast of Spain, a space shortage in the country’s migrant detention centers left few options for where to send the new arrivals.

So the government sent them to an empty facility near this whitewashed town in the mountainous heartland of southern Spain, about 35 miles north of Málaga: its brand-new prison.

Archidona’s penitentiary stands a few miles outside the town, amid olive groves that were covered in snow last weekend. Designed to hold about 2,000 prisoners, with a staff of almost 600, it was due to open in the first quarter of this year.

The arrival of the migrants, in November, has provoked mixed feelings.

Many of the town’s 8,400 residents helped collect food and clothing for them. Then the migrants held protests in the prison — smashing windows and furniture, and prompting the stationing of riot police officers in Archidona, according to the authorities. Some residents voiced concerns about possible damage to the new prison even before its official opening.