Imam Abdelbaki Es Satty radicalized the young men accused of killing 15 people and wounding more than 120 in two Spanish cities according to court testimony from one of the terror-cell’s four suspected surviving members in Madrid Tuesday.

The 45-year-old Es Satty spent four years in Spanish prison for smuggling hashish between his native Morocco and Spain in 2010, according to the UK Telegraph.

While there, he spent time with Rachid Aglif, one of the men behind the 2004 bombings in Madrid that killed 196 people, according to reports.

Upon his release in 2014, Es Satty was ordered to leave the country under Spanish immigration law, but he appealed, convincing a judge that his deportation would be an infringement of his international rights, the Telegraph reported.

He briefly worked as an imam at a Belgian mosque in 2016, but was fired because he refused to produce papers proving he had a clean criminal record, according to a Newsweek report.

Es Satty returned to Spain that year, teaching at two mosques in the town of Ripoll, where the suspected attackers lived.

He is believed to have been killed when a residence in the town of Alcanar that housed the 12-man cell’s bomb-making operation exploded last Thursday.