The remains of the house in Alcanar where Abdelbaki Es Satty's body was found. Josep Lluis Sellart

Spain’s National Intelligence Center (CNI) admitted on Thursday that it had “had contact” with the mastermind of the terror attacks in Catalonia this summer, Abdelbaki Es Satty, during the time that he was in prison in Castellón, between 2010 and 2014. The Spanish secret service did not, however, clarify how often these contacts took place, nor the duration, nor whether they were paid. They did state that they took place within the “protocol established for convicts” in prison and who have maintained relationships with jihadists.

The imam from the small Catalan town of Ripoll who headed the jihadist cell behind the terrorist attacks in Barcelona and Cambrils in mid-August in which 16 people died, was no stranger to Spain’s security forces. Apart from having been investigated as part of the Chacal operation into Islamic jihadism – carried out after the 2004 Madrid train bombings that killed 193 people – it has now emerged he was an informant for Spain’s National Intelligence Center (CNI) during his time in a Castellón prison where he served four years for drug trafficking.

This has been confirmed by sources from the Spanish secret services, although they have not specified for how long the imam worked for them, or whether he was paid.

Es Satty died in an explosion at a house in Alcanar (Tarragona) while preparing explosive material for major attack.

Those same sources clarified that the contacts established with Es Satty “fall within the usual protocols of the agency,” and that it is “normal to obtain information to fight terrorism from those in prisons who may have information.” In any case, Es Satty was not sent to prison for terrorism offenses, but rather for drug trafficking.

Born in the mountainous Rif region of Morocco, Es Satty had tried to transport 121 kilos of hashish into Spain but was caught at the border with the Spanish exclave of Ceuta in North Africa. However, CNI sources say that “he had contacts with jihadists,” presumably to help them leave leave Spain, according to other sources from the counter-terrorism fight.

According to Es Satty’s statements during his drug-trafficking trial, he was blackmailed into trying to transport both drugs and people into Spain, although he never provided any evidence of this.

While the case being led by Judge Fernando Andreu with Spain’s High Court is still under judicial seal, these new details coming out suggest that Es Satty was no stranger to the state’s security forces and that he had been known to them almost since he arrived in Spain in 2002. His name appeared in the address books of some of those arrested for 2004 Madrid train bombings. He was also investigated as part of the Chacal operation against terrorism although wire taps failed to provide enough evidence to see him formally accused of a crime. He was arrested for drug trafficking in 2010 and he served out all of his four-year sentence.

In Vilvoorde, Belgium he offered his services as an imam in 2015, after leaving prison. But he raised suspicions and a local police officer asked for a background check from Catalan police. Indications point to the fact that the Catalan police were the only security force in Spain who did not have a file on him. If he had been registered, with his criminal record noted, he would not, in theory, have been able to practice as an imam in Ripoll. However, he began doing so in 2015.