As the dust settled over five days of angst in Spain after deadly terror attacks, the four remaining alleged members of a terror cell that carried out the carnage arrived in a Madrid court on Tuesday for questioning.

Spanish police shot dead Barcelona terror suspect Younes Abouyaaqoub on Monday in a dramatic end to a massive manhunt for the Moroccan national, who shouted ‘Allahu Akbar’ (God is greatest) when he was killed.

The Moroccan was the last on-the-run member of a 12-man cell suspected of plotting last week's vehicle attacks in Barcelona and the seaside resort of Cambrils that left 15 dead and more than 100 injured.

Four men were detained, and the rest were killed, either by police or in an explosion believed to have been accidentally detonated by the suspects themselves in their bomb factory in the seaside town of Alcanar.

Among those killed in the explosion was a Moroccan imam at the heart of the cell, Abdelbaki Es Satty, Catalan police chief Josep Lluis Trapero confirmed.

On Tuesday under heavy security, police vans carrying the suspects entered the National Court, which deals with terrorism cases, where a judge will decide what -- if any -- charges to press against the four men who allegedly formed part of the cell.

These include Driss Oukabir, 27, the older brother of Moussa who was killed by police in Cambrils on Friday morning after going on a car rampage with four others.

Mohamed Aallaa, Mohamed Houli Chemlal, who was injured in the explosion in Alcanar, and Salh El Karib were also in court.

Police gave their ages as 21, 28 and 34 but did not say who was what age.

- 'This had to end' -

Four days after the van rampage on the tourist-packed Las Ramblas boulevard, police on Monday gunned down the 22-year-old Abouyaaqoub in the village about 60 kilometres (40 miles) west of Barcelona, after receiving multiple tip-offs.

In Abouyaaqoub's hometown Ripoll, where many of the suspects grew up or lived, Moroccan factory worker Hassan Azzidi said he was ‘happy and sad all at once’ that the suspect had been gunned down.

‘This had to end, because we're living as if in a war, but at the same time, someone brainwashed such a young boy,’ he said.

In total, 15 people died in the attacks including Pau Perez, a 34-year-old man found stabbed to death outside Barcelona on Friday after Abouyaaqoub hijacked his car to make a getaway.

- Imam's influence -

Investigators seeking to unravel the terror cell had homed in on the small border town of Ripoll at the foot of the Pyrenees mountains in northeastern Spain.

Satty, aged in his 40s, came under scrutiny as he is believed to have radicalised youths in Ripoll.

Police said the imam had spent time in prison and had once been in contact with a suspect wanted on terrorism charges but was never himself charged with terror-related incidents.

In Belgium, the mayor of the Vilvorde region told AFP that Satty spent time in the Brussels suburb of Machelen -- next to the city's airport -- between January and March 2016.

In the Moroccan town of M'rirt, relatives of Abouyaaqoub have accused the imam of radicalising the young man as well as his brother Houssein.

‘Over the last two years, Younes and Houssein began to radicalise under the influence of this imam,’ their grandfather told AFP.

The suspected jihadists had been preparing bombs for ‘one or more attacks in Barcelona’, Trapero said Sunday, revealing that 120 gas canisters and traces of TATP components -- a homemade explosive that is an IS hallmark -- had been found at their bomb factory.

The accidental explosion in the house in Alcanar, south of Barcelona, may have forced the suspects to modify their plans.

Instead, they used a vehicle to smash into crowds on Barcelona's Las Ramblas boulevard, killing 13 people and injuring more than 100.

Several hours later, a similar attack in Cambrils left one woman dead. Police shot dead the five attackers there, some of whom were wearing fake explosive belts and carrying knives.

Hundreds of Muslims rallied Monday at Las Ramblas, holding slogans like ‘No to terrorism’ and ‘We are Muslims, not terrorists’.

Related Story