Candles and flowers are placed on the ground after a terror attack in Barcelona. (Santi Palacios/AP)

The terrorist cell in Spain that unleashed a pair of deadly vehicular attacks was planning a much more lethal, more dramatic act. Its members were going to explode huge bombs at monuments in the center of the city, according to a court official.

Mohamed Houli Chemlal, 21, who police say is one of the surviving members of the cell, told a court in Madrid that the members were assembling bombs in a safe house under the guidance of their imam, who told them he planned to blow himself up during the attack. 

Spanish media reported that Houli Chemlal said one of the possible targets was Antoni Gaudí’s iconic and unfinished Roman Catholic church in Barcelona, Sagrada Familia.

The imam appears to have recruited the teens and young men in the terrorist cell from the Moroccan immigrant community in the mountain town of Ripoll, a two-hour drive north of Barcelona. 

Houli Chemlal’s initial testimony to Judge Fernando Andreu in a closed Madrid courtroom on Tuesday was reported widely by Spanish media and sourced to a court official. The judicial source spoke on the condition of anonymity because he was not permitted to brief reporters on the proceedings before a special anti-terrorism tribunal, where the judge is to decide on charges and whether the defendants can be freed on bail.

Spanish police shot and killed Younes Abouyaaquob, 22, in the small town of Subirats. Officials found a fake suicide bomb vest on the man after deploying a robot. (Raul Gallego Abellan for The Washington Post)

At least two of the defendants, through their families and friends in Ripoll, have said they were unwitting participants — that they simply rented vans one thought were for moving or sold airline tickets and transferred money.

The judge charged two of the defendants with terrorism offenses. He ordered the release of one suspect, a brother of a member of the cell who was killed by police. A fourth suspect, who ran an Internet cafe and cellphone business, was ordered held for questioning.

Houli Chemlal was shown being escorted into the court by police, shackled, with one arm bandaged, and wearing hospital pajamas. He is the lone survivor of an explosion last Wednesday that destroyed a house in Alcanar, south of Barcelona.

Police say the house contained 120 tanks for propane gas, alongside residue of a bomb-making material known as TATP and remote-controlled detonators. On Wednesday, investigators said they also recovered a belt with explosives at the house.

In an earlier briefing with reporters, Josep Lluís Trapero, chief of the Catalan national police, said that his investigators assumed the explosion in Alcanar was an accident, which killed the imam and triggered the cell to launch the vehicular attacks Thursday.

In the first, police say, Younes Abouyaaquob, 22, drove a white rental van down La Rambla avenue and killed 13 in a boulevard crowded with international tourists and locals. An hour later, police said, Abouyaaquob stabbed a motorist to death and used his car as a getaway vehicle. Later, five members of the cell drove into a crowd near a police checkpoint and killed a female bystander.

Mohamed Aallaa (center), 27, is one of four who have been arrested in connection to the terrorist attacks in Spain. (J.J.Guillen/EPA)

Catalan officials said their investigation was swift and successful, and Trapero said it was dirty politics to place blame on police instead of the terrorists.

Still, there appeared to have been missed opportunities.

The Moroccan imam alleged to be at the heart of the conspiracy, Abdelbaki Essati, was sent to prison for four years, from 2010 to 2014, for smuggling hashish into Spain. 

A counterterrorism officer in Spain, who spoke on the condition of anonymity to share background information on an open investigation, said Essati had a pending deportation order.

The director of the mosque where Essati preached and taught children Arabic and the Koran said they passed his name to local police as part of Spain’s program to monitor the mosques.

A Spanish police adviser noted that Essati’s name appeared, but just once, on Page 70 of a Justice Ministry report on the arrest of five men in a town south of Barcelona, on charges of recruiting local youths to fight in Iraq.

The president of the Catalan region, Carles Puigdemont, brushed aside criticism of the local forces, saying now was not the time to air grievances between Catalonia and the national government in Madrid. 

But Puigdemont told The Washington Post that information about a suspicious imam “was not in the hands of the Catalan police.” 

The regional president added that forces here have been denied membership in Europol, which coordinates Europe’s response to transnational terrorism, as well as Spain’s anti-terrorism center. 

“Information reaches us now through the Spanish police, but we do not yet have our own intelligence agency; we don’t have it,” he said.

Puigdemont said there are 200,000 Moroccan immigrants living in Catalonia. “If 200,000 people were radicalized, we’d have a very serious problem, but they aren’t all radical. They are our neighbors and therefore, the Catalan society, which is very diverse, is working well.”

Counterterrorism officials last year issued an alert warning that Spain was consistently mentioned in propaganda material produced by the Islamic State, which has claimed its soldiers were behind the recent attack. In 2004, bombings on the Madrid rail system killed 191 people and injured more than 1,800. Spanish officials blamed an al-Qaeda cell.

After the explosion in Alcanar, police and firefighters did not suspect that a terrorist cell was making bombs. Instead, they thought that thieves were dealing in stolen propane tanks — or that perhaps drug dealers were manufacturing methamphetamine. 

As it turned out, two bodies were recovered from the site. Police think one is that of the imam and are awaiting final DNA confirmation.

Telling, too, is the fact that Houli Chemlal was found wounded there but was not interviewed as a serious suspect in the terrorism case until the van attack in Barcelona.

Raul Gallego Abellan in Subirats and Angel García in Barcelona contributed to this report.