LA POBLA DE CLARAMUNT, Spain — When María José Rodríguez heard on local television that her town in northeastern Spain would be locked down within hours, she knew she had to leave or risk losing her family’s business.

She grabbed a bag of groceries, a fresh change of clothes and her car keys, said goodbye to her husband and drove to her son’s apartment in a nearby village, above the family bakery. For more than two weeks, she has been locked out of the town, Igualada. Her husband has been locked in, and they have no way of knowing how long it will go on.

“Had I not moved out to keep running the bakery, we would have had to close it,” Ms. Rodríguez, 63, said at her shop in the village of La Pobla de Claramunt. “But we’ll be fine, and I call my husband 50 times a day. At the very least.”

Many European countries have imposed various forms of lockdowns to contain the epidemic, but Igualada, an industrial town 30 miles northwest of Barcelona, stands out. Even as Spain has imposed a nationwide lockdown, it has cut Igualada off from the rest of the country — a lockdown within a lockdown.