In this combination photo, four un-named alleged members of a terror cell accused of killing 15 people in attacks in Barcelona leaves a Civil Guard base on the outskirts of Madrid before appearing in court in Madrid, Spain, Tuesday Aug. 22, 2017. Four men were arrested last week for their alleged involvement in the planning or execution of attacks in Barcelona on Thursday and the northeastern resort town of Cambrils early Friday.(AP Photo)

In this combination photo, four un-named alleged members of a terror cell accused of killing 15 people in attacks in Barcelona leaves a Civil Guard base on the outskirts of Madrid before appearing in court in Madrid, Spain, Tuesday Aug. 22, 2017. Four men were arrested last week for their alleged involvement in the planning or execution of attacks in Barcelona on Thursday and the northeastern resort town of Cambrils early Friday.(AP Photo)

MADRID (AP) — An extremist cell was preparing bombs for an imam who planned to blow himself up at a Barcelona monument, a key suspect in the attacks that killed 15 people in northeastern Spain told a judge Tuesday, according to a judicial official.

The suspect, Mohamed Houli Chemlal, was one of four men taken before Spain’s National Court in Madrid to testify about the Islamic cell that attacked pedestrians in Barcelona and the nearby seaside town of Cambrils last week.

ADVERTISEMENT

National Court Judge Fernando Andreu questioned the four about the vehicle attacks as well as the fatal explosion at a bomb-making workshop that police said scuttled the group’s plot to carry out a more deadly attack at unspecified Barcelona monuments. After the session, the judge ordered two of the surviving suspects held without bail, another detained for 72 more hours and one freed with restrictions.

A Spanish judicial official said Houli Chemlal, 21, and suspect Driss Oukabir, 28, identified imam Abdelbaki Es Satty as the ideological leader of the 12-man cell.

Oukabir and the other two surviving suspects who testified, Mohamed Aalla and Sahal El Karib, denied being part of the cell, said the court official, who was not authorized to discuss the case and insisted on speaking anonymously.

The cell’s other eight members are dead. Police shot five during an attack Friday and one more Monday after a manhunt. Es Satty and another accidently blew themselves up while preparing explosives in a house in the coastal town of Alcanar, south of Barcelona.

Es Satty preached in a mosque in the northeastern town of Ripoll, home to most of the 12 pointed to by police as suspected members of the cell. Police identified his remains amid the rubble of the Aug. 16 explosion that destroyed the house in Alcanar.

Police found in the house over 100 tanks of butane gas and materials to make TATP, an explosive frequently used in attacks by Islamic State militants. The group has claimed responsibility for both attacks on pedestrians — one Thursday by a van that mowed down people on Barcelona’s famed Las Ramblas promenade and another early Friday in Cambrils. The attacks and a bloody getaway in which a man was stabbed to death left 15 dead and over 120 wounded.

Houli Chemlal, the only survivor of the Alcanar blast, told the court Tuesday that he is alive because he was on the ground floor of the house washing dishes after dinner. He testified from a wheelchair without lifting his eyes up from the ground, according to the court official. He has been hospitalized under guard since his arrest Thursday.

ADVERTISEMENT

The second suspect interrogated, Oukabir, testified he rented the vans used in the attacks on pedestrians but said he thought they were going to be used for a house move. His brother Moussa was one of the five radicals shot dead Friday by police in Cambrils.

According to another person who attended Tuesday’s interrogation, Oukabir told the prosecutor that his first version of events — telling police his documents were stolen by his brother — was something he had done out of fear. The person spoke on condition of anonymity to discuss the hearing.

The third suspect, Aalla, said an Audi A3 used in last week’s attack in Cambrils was registered under his name but used by another sibling, the judicial official said. Police say one of Aalla’s younger brothers died in Cambrils and another one is believed to be the second casualty in the Alcanar house blast where the imam died.

The last surviving suspect, El Karib, the owner of a cybercafe in Ripoll, told the judge that he was only trying to make a profit when he bought at least two plane tickets for two alleged members of the cell.

Police later Tuesday raided the cybercafe in Ripoll as well as a house in Vilafranca del Penedes, searching for more evidence.

After the questioning, the judge said there was enough evidence to hold Houli Chemlal and Oukabir on preliminary charges of causing homicides and injuries of a terrorist nature and of belonging to a terrorism organization. Houli Chemlal also has an additional charge of dealing with explosives.

However, the judge ruled the evidence was “not solid enough” to keep holding Aalla, who was freed on condition he appear in court weekly, relinquish his passport and not leave Spain.

El Karib will remain in custody for at least 72 more hours while police inquiries continue, the judge said.

The lone fugitive from the initial attack, 22-year-old Younes Abouyaaqoub, was shot to death Monday west of Barcelona after a big, dayslong manhunt. Police say he flashed what turned out to be a fake suicide belt at two officers who confronted him in a vineyard.

Police said they had “scientific evidence” that Abouyaaqoub drove the van that barreled through Barcelona’s crowded Las Ramblas promenade and that he hijacked a car and fatally stabbed its driver while making his getaway.

Abouyaaqoub’s brother and friends made up the rest of the 12-man extremist cell, police say.

Chemlal was born in Melilla, one of Spain’s two North African coastal enclaves that have borders with Morocco. Spanish media say the other 11 suspects are all reportedly Moroccans who lived in Spain.

___

This story has been corrected to show that 13 people were killed in the Barcelona van attack and to correct the spelling of one suspect’s surname to Chemlal and another suspect’s name to Sahal El Karib.

___

Associated Press writer Ciaran Giles in Madrid contributed to this report.