Until Thursday, just hours before the Barcelona attack, many of the young men seemed to be living completely normal lives. One had slept late, his mother said. Another had worked as a waiter serving wine in a mountaintop restaurant days before. Several were eating kebabs, looking relaxed.
By Friday morning, seven were dead, an eighth was critically wounded, and one was on the run. Three others were detained by the police.
They had grown up together, and among them were four sets of brothers. Most of them were not even 25 years old.
All 12 are now suspected by investigators of having played a part in the attacks that killed 14 and wounded more than 80. Most of the victims died after being run over on Las Ramblas, the main pedestrian boulevard in Barcelona, blighting Spain’s recent image as a place relatively untouched by terrorism and rattling nerves across Europe.
“These guys were normal, they said ‘hello, goodbye,’ they all worked, they had cars, they had parents,” said Habiba al Loquiat, a resident of Ripoll, the small town where many of them lived, and where Ms. Loquiat attended a gathering on Saturday of Moroccans in solidarity with the victims. “They didn’t live in misery. Everything was normal in the last months and one day I see on TV, it’s over.”
“The community doesn’t have problems,” she said. “Why did they do these things?”
There is much that investigators have yet to learn, but based on interviews with the men’s friends, neighbors, religious figures and the police, the answer appears to lie at least in part with a shadowy figure linked to the Islamic State, Abdelbaki Essati, who is believed to have been killed on Wednesday, a day before the attack, when explosives that the group was manufacturing accidentally detonated.
Mr. Essati, who was in his 40s and who is reported to have had links to Islamist extremists going back at least a decade, somehow brought the young men under his influence after establishing himself as an imam in their mountain town of Ripoll, even though few of the young men had a history of regularly attending mosque.
In an eerie resemblance to recent attacks in Paris and Brussels, Mr. Essati appears to have targeted groups of brothers, perhaps because family ties make it harder for individuals to leave the group, even if they want to go to the police.
Of the four sets of brothers involved in the attacks in Catalonia, one family may even have had three brothers active in the cell, investigators believe. In the Paris and Brussels attacks, there were at least two sets of brothers involved.
Unlike in those cases, however, there has been little discussion so far of internet radicalization in this attack. Instead, there appears to have been a concerted effort through personal contact — although internet resources seem to also have been used eventually — to radicalize the young men.
Investigators and terrorism experts believe that the planning for the plot may have begun not long after Mr. Essati’s arrival a year ago at the second of two mosques where he worked in Ripoll. They now say that at least some of the suspected participants traveled abroad before the attack either to Morocco or elsewhere in Europe, as did Mr. Essati.
The young men all knew one another — to varying degrees — and most had attended the same middle school and high school.
As was the case in previous attacks linked to the Islamic State, the conspirators in this plot covered their tracks by meeting in different places and using a low-profile location as a bomb-making center.
Setting up as squatters in a vacant house in Alcanar, a working-class holiday town about 186 miles away, they created a makeshift explosives factory. In plain sight of neighbors who suspected no wrongdoing, they gradually collected more than 100 cylinders of butane gas, the police said, in an effort to intensify the damage that would be done by the car bomb they were making.
It was to be detonated using triacetone triperoxide — a volatile and unstable substance, known as TATP, that was also used in the Paris and Brussels attacks. The accidental explosion on Wednesday suggests that assembling the bomb was beyond their skills.
After the group’s safe house blew up — killing its leader and two others — those who were still alive appear to have had no clear backup plan.
First they carried out the plot to run a vehicle into crowds on Las Ramblas, but after that they seemed adrift. Five of them piled into one car and late on the night of the Barcelona attack tangled with the police in Cambrils, a seaside town, as they tried to run over more people. All were killed by the police in a shootout.
Unlike the attackers in Paris and Brussels or in Nice or London, these young men were from well integrated Spanish-Moroccan families. None had previous links to terrorism or were on watch lists, the police said, and most either had jobs or were still in school. Only a couple of them appeared to have had minor brushes with the law — for marijuana use.
“When there is an attack like this, we then always focus on certain districts or banlieues,” Carles Puigdemont, the leader of Catalonia, told a news conference on Sunday. That was pointless here, he protested.
“We have about 200,000 Moroccans in Catalonia who contribute to the normality of this country, who pray, work and take part in our collective life, and as such it is very unfair to try to present a community that has an important proportion of Muslims as a hot spot of radicalization.”
Few of the young men appear to have been drawn to religion. Several partied and readily smoked joints, according to friends. The one set of brothers whom friends describe as more involved religiously were the Abouyaaqoubs.
A close childhood friend of Houssaine Abouyaaqoub, 19, described him as becoming more religious in the last year, but he also went to the gym regularly, taught rock climbing and, like a couple of the others, spoke fluent Catalan.
“Younes, his brother, was always more religious,” said the friend, who asked not to be identified because he was afraid to have his name published in the current climate. “Houssaine would go often to that mosque, but not every day or every week. But in the last months he went more often than before.”
Another friend described Houssaine as changing abruptly, and suddenly starting to talk only about “religion, religion, religion.”
The change, he said, came after Houssaine went on a trip with the imam to Tarragona, for about two weeks, a month ago.
“It happened very fast,” he said.
Another suspect, Mohammed Aalla, 27, worked as a waiter in a mountaintop restaurant in the hamlet of Ventola, where he served wine and alcohol along with the other waiters, his employer said.
The police believe he was involved along with his brothers, Said, 18, and Youssef, 22.
The youngest participant was Moussa Oukabir, 17, who went to the mosque only a couple of times, said the head of the association that runs the local mosque where Mr. Essati most recently served as imam. A slender boy with a shy expressions in photographs, Moussa impressed others with what one neighbor said was “perfect Catalan.”
Friends and neighbors said that Moussa liked to swim, ride his bike and hang out near the river that runs through the town.
His sisters boasted to their employer at Les Graelles, a local restaurant, that he had received high marks in school. “The little brother was a 10 kid, a great kid,” said Rosa, the restaurant’s manager.
Yet about two months before the attack, friends said, Moussa Oukabir bought a plane ticket to Morocco from a local phone and internet store that also sells cheap flights. It is not clear when he went or how long he stayed.
His brother, Driss, 27 or 28, had some scrapes with the law for selling marijuana.
He walked into the police station in Ripoll after his identity documents were used to rent the white Fiat van that ran over people on Las Ramblas and the papers were discovered inside. Driss Oukabir said that the documents had been stolen and that he had come in to report the theft.
He remains in detention. There is no suggestion that he was the driver of the vehicle, but questions remain about whether he knew that his documents would be used in a terrorist attack.
Upstairs from the Oukabir family lived the Hychami family, including Mohammed, 24, and Omar, 21. Mohammed worked in the nearby Conforsa factory, which manufactures machine parts. He told his mother, Halima Hychami, that he had vacation from July 20 until Aug. 27.
The last time she spoke to her elder son was early last week, when she was visiting her family in Morocco.
“Mohammed called me — I was coming back on Wednesday — and he said, ‘Mom, everything is ready. Who do you want to have pick you up at the airport, me or Omar?’
“I said, ‘If Omar comes, when will I see you?’ And he said, ‘Saturday or Sunday.’
“That was the last time we talked,” said Ms. Hychami, who wore a long black abaya, a silent statement of mourning as she spoke to a few reporters in the main square in front of Ripoll’s town hall.
It turned out to be Omar who came to pick her up at the airport.
About 12 hours later, both of her sons were shot dead by the police in Cambrils after the Audi they were driving, which belonged to a suspect who is now detained, tried to break through a police checkpoint and drove into tourists, killing one person and wounding a half dozen others.
The emotional scars on the young men’s families and communities are not counted in the toll of victims, but have nonetheless left their mark.
“I wish this had never happened and that our only memory of our children was the innocence in their eyes,” said Hafa Mars, an educator who worked with many of the young men when they were children and who attended the demonstration in Ripoll in support of the victims on Saturday.
“I wish we didn’t have to remember them the way we do,” she said. “We don’t know whether to cry for them or what to do, because they have killed 14 people.”