BARCELONA, Spain — When an earthshaking explosion on Wednesday blew apart a house outside Alcanar, a town surrounded by olive groves and holiday homes overlooking the Mediterranean, the police first blamed it on a gas leak.
“Nothing ever happens here,” Mayor Alfons Monserrat said.
The Spanish police now believe that tiny Alcanar may have been the incubator for a conspiracy far more ambitious than even the van attacks in Catalonia that killed 14 people and injured more than 80. All but one of the casualties occurred Thursday afternoon on the Ramblas, Barcelona’s colorful central thoroughfare. It was Spain’s worst terrorist attack in more than a decade, and the Islamic State has claimed responsibility.
The Alcanar blast, they suspect, was a mistake by the plotters, who had intended to make a powerful bomb, place it in a van and detonate it in the crowded center of Barcelona. That plan disintegrated along with at least 12 butane gas canisters that were discovered in the ruins of the house in Alcanar on Wednesday night.
Four men have been detained in the case, and three more who have been identified remain at large, according to Maj. Josep Lluis Trapero, a senior police official in Spain’s Catalonia region. Investigators are still trying to determine the full extent of the network. Five of the suspects are dead, at least three of them appearing to be so young that they could not have grown beards. They were killed by the police during a second attack, in the seaside holiday town of Cambrils early Friday.
While some of the other recent European terrorist attacks have been opportunistic hit and runs by individuals acting on their own, this was a comparatively complicated plot that the police say involved at least two cells working in several different locations across Catalonia.
The story also unfolded in Ripoll, hometown of one of the young men who was killed in Cambrils. His brother was arrested after his identity documents were found to have been used to rent the van used to carry out the attack on Las Ramblas. At least one other person from Ripoll has been detained.
There were few indications that the two brothers, Driss Oukabir, 28, and Moussa Oukabir, 17, had come under the influence of radical Islam. Ripoll is a mountain town northwest of Barcelona of about 10,000 people, and Moussa and Driss Oukabir, both of Moroccan descent, lived there with their mother.
Among neighbors, friends, former employers and the local mosque, no one saw any outward sign of budding extremism. The elder brother, Driss, spoke perfect Catalan as well as Spanish and was not religious, according to a childhood friend, Raimon Sánchez, 27. He was known as a small-time marijuana dealer, but nothing more.
“We went to school together; after that everyone went his own direction, but when we saw each other, we would say hello, smoke a joint together,” Mr. Sánchez said. “He was in my home when he was a child — how can a person change that much?”
Moussa was well liked by everyone. He also spoke perfect Catalan, said a neighbor. His sisters, Hafida and Hanane, described him to their former employer at Les Graelles, a local restaurant, as polite, “having really good marks in school” and eager to study. “He didn’t go to parties,” said the restaurant’s manager, Rosa, who said she was afraid to give her last name.
There was no sign that the family was particularly religious, she added. Neither sister wore a head scarf except when they were coming from the mosque and never when they were working.
The family lived in a nondescript apartment building near the southern edge of town that serves as social housing for lower-income people.
There were three Spanish-Moroccan families in the building, and Moussa, the youngest of the Oukabir children, was good friends with them as well as other children who lived there, neighbors said. A 15-year-old Catalan boy in the building said that he used to go swimming with Moussa and played with him by the river that runs through town, and that they rode their bikes together.
“Moussa never spoke about religion,” said the boy’s mother, Marche, who lived in the apartment directly next door. “He was a good kid, just like you or me.”
She said that Moussa and Driss’s parents had recently separated, but that she was shocked when masked police officers burst into the building at 7 a.m. on Friday and broke into the Oukabir apartment. She did not know if they had found anything.
From the open door, it appeared to be a modest apartment with three small bedrooms, two of them with just enough room for a single bed and a flimsy wardrobe. Clothes were strewn all over the floor from the raid. It was not clear whether anyone was present when the police burst in.
At the mosque closest to the family’s home, Ali Yassini, who works with the mosque’s Islamic Council, said he had barely any contact with the brothers. “We don’t know them; we saw them maybe once a year,” he said, adding that among Muslim youth in Ripoll there is a generational divide. “The young ones want to party; these kids, 24 years and younger, they feel they are in jail here.”
On Thursday afternoon, one of the attackers arrived at a branch of Telefurgo, a car rental firm, some 15 miles north of Barcelona. Using the identity documents of Driss Oukabir, he paid 59.90 euros (about $ 70), on top of a 150-euro deposit, to hire a white Fiat Talento, the firm told Spanish journalists.
Chander Gurnani, 34, who runs a souvenir shop in central Barcelona, first saw that white Fiat Talento at around 5 p.m. on Thursday as it plowed into a young woman, sending her flying through the air. Then it mowed down an old man whose head began to gush blood. Rushing from his shop, Mr. Gurnani, an Indian immigrant, said that he took the man in his arms — before realizing some 30 seconds later that he was already dead.
So began Thursday’s attack on Las Ramblas, the long boulevard that connects the city’s port with its most central districts. The van veered south from Plaça de Catalunya, the city’s most recognizable square, zigzagging from side to side to hit as many people as possible.
After mowing down at least a dozen people across a stretch of some 1,600 feet and slamming into dozens more, it crashed into displays of cheap souvenirs — phone covers, bracelets, drawings and even oven gloves — skidding to a halt on a public artwork by Joan Miró, the Catalan artist.
The driver quickly melted into the crowds.
A waiter at a nearby restaurant had no idea why so many people were rushing inside. Nobody explained what was going on, remembered Guldeep Singh, 30, who was back at work less than a day after the attack.
“They were screaming,” Mr. Singh said. “They were in shock. They didn’t have words.”
For Mr. Singh, the penny dropped when he looked outside to see two people prostrate on the street. By the time an ambulance arrived 20 minutes later, one of them was dead.
Those stuck in the shops and bars of Las Ramblas had little idea about the events that had led them to flee there.
Outside, however, a picture of a complex operation was beginning to emerge. A second van was discovered in Vic, north of Barcelona; the police now think the assailants used it to flee central Barcelona after the attack.
Photographs of Driss Oukabir, whom police had quickly linked to the van hire, began to circulate, prompting him to turn himself in at a police station in Ripoll. He claimed his documents had been stolen and that he was not the man who hired the van.
Down in Alcanar, another man was arrested in connection to the attack. Then, the Islamic State, also known as ISIS or ISIL, claimed responsibility for the events, in a statement issued through its news agency.
For many survivors, shock and fear now began to give way to relief. A Spanish tour guide, Laia Escribano, had unwittingly taken a group of tourists to the street just minutes afterward and gradually realized how narrow her escape had been.
“I am lucky to be alive,” said Ms. Escribano, 31. “If the attack was 10 minutes later, I would have been right there with the students on the tour.”
But as Thursday rolled into Friday, relief gave way to renewed terror. In Cambrils, a small seaside resort town about 50 miles south of Barcelona, another car attack was unfolding.
At 1 a.m., five assailants in an Audi A3 hit a group of civilians before police officers fatally shot five of them, among them Moussa Oukabir. A pedestrian later died after being hit by the car, and the police have confirmed that the Cambrils attack was committed by the same network that sent a van to Barcelona.
In a night of strange developments, however, the oddest of all was perhaps the news from Alcanar. Twenty-four hours after the authorities considered the explosion there a gas leak, the story came full circle.
Alcanar, the police now suggest, was not just a sleepy holiday town. It may have been a place where the attacks were planned — news that shocked local residents.
“You might think all sorts of things,” said Nuria Gil, 50, one of the few locals who lives here year-round, “but not that you have terrorists as neighbors.”