In the Spanish border town of Ripoll, everyone knows each other -- making it all the more shocking to residents that jihadists believed responsible for this week's deadly twin attacks lived among them.

"You are neighbours your entire life and they end up doing this," said Maria, a waitress in the town of around 10,000 inhabitants, who declined to give her full name.

Most were children of Morrocan immigrants, including Ripoll-born Moussa Oukabir, 17, one of five "suspected terrorists" shot dead after the Cambrils attack.

Likewise, his neighbour Mohamed Hychami, 24 and Said Aallaa, 18, who were in the car turned into a deadly weapon, called Ripoll home.

At least three of four other suspects detained were also inhabitants of the little town that attracts skiers en route to the Pyrenees mountain range bordering France.

And on Saturday, officers raided the apartment of an imam in Ripoll, according to his flatmate who gave his name only as Nourddem.

"The last time I saw him was Tuesday and he told me that he was going to see his wife in Morocco," Nourddem told AFP.

But Spanish daily El Pais, quoting police sources, said the imam may have been one of those killed in an explosion in a home in Alcanar, some 200 kilometres south of Barcelona, where the alleged jihadists were believed to have been building bombs.

'They came in for a beer'

Everywhere across town, the dismay that one of their own had carried out the deadliest attack in Spain since 2004 was palpable.

Stunned locals looked on as heavily armed officers raided several homes on Friday, including one next to the central Plaza Grande square filled with cafe terraces.

A waiter at one of the cafes told AFP he had served beers to the suspects numerous times, most recently just two days ago.

"They came to have beer at another bar in the square where I used to work. Two days ago they came, two of them and a child. They had a Heineken, a cafe au lait and the child had a juice," said the waiter, who declined to give his name.

The suspects behaved normally, and gave no reason to be watchful of them, he added.

"Of course it is surprising," a customer of one of the bars, Alberto Batlle, told AFP of the attacks.

"You usually see these things on television happening in other countries and you always believe it will continue to happen to others. And it really affects you, when it happens in Barcelona and it is the work of people from Ripoll."

Yasmila, the neighbour of one of the alleged jihadists, also said that the suspect, Said Aallaa was a hardworking and good youth.

"A friend apparently called him on Thursday at 3pm and he went out for a drive," she said, recalling the event two hours before the Barcelona attack.

Signs of radicalisation

But other locals say there had been visible signs that some may be radicalised, including some women who were starting to wear veils while others had become less social.

A mosque that opened in 2008 has also been subject to controversy in the town which is also home to a monastery that dates to 888, according to media reports.

More recently, a column in a local newspaper had urged state authorities to "check the speech of some imams who were preaching during Ramadan".

"Those who know these north Africans are not surprised," said a man of around 60.

"You can't say that, there're not all the same," was the retort of a woman, who lived next door to Moussa Oukabir.

She added that Moussa's younger brother, Driss, is a "very well-raised boy".