The man who masterminded the terror attacks that killed 16 people in Barcelona and another seaside resort in August had worked in cooperation with the Spanish secret service, leading Spanish newspaper El Pais reported Friday, citing a secret service official.

Abdelbaki Essati was approached by the secret service while serving a sentence for drugs charges in 2014, the official said, speaking on the condition of anonymity.

According to El Pais, Essati was not a formal informant, but rather one of the secret service's contacts for obtaining information about extremists.

Essati died at his bomb-making workshop in Alcanar, south of Barcelona, days before the Aug. 17-18 attacks. All of the cell's members were either killed or jailed.

He was believed to be leading a major Daesh cell whose members were mostly of Moroccan origin and included some teenagers.

His ties to extremism date back to 2006, when his apartment in Vilanova was raided by Spanish police over recruitment of a fighter to the Iraqi war.

Shortly after the report, Spain's government said it could not comment whether Essati had once been an intelligence agency informer.

Government spokesman Inigo Mendez de Vigo said a secrecy order had been placed on the investigation.

In the Barcelona attacks, terrorists killed 16 people using vehicles and knives in a two-pronged attack in the city and at the seaside resort of Cambrils, with the bloodshed later claimed by Daesh.

The main suspects were of Moroccan origin, although most had lived in Spain for several years.