RIPOLL, Spain — He sometimes wore jeans and dressed like a “hipster,” and had only a short beard. He was unfailingly courteous and studiously discreet. And it seems that he trained the young men he lured into his terrorist cell to behave in much the same way, carrying on double lives that betrayed little of their real intentions.

Abdelbaki Essati, the shadowy imam who the authorities believe was at the center of last week’s terrorist attacks in and near Barcelona, Spain, appears to have been a master of deception. His associations with jihadists reached back more than a decade, but he managed to evade the scrutiny of authorities and the suspicion of many in Ripoll, the small town in northern Catalonia where he showed up last year to offer his services.

Mr. Essati’s technique, according to terrorism experts, was taken right from the playbook of the Al Qaeda jihadi recruiters with whom he had first come into contact at least 11 years ago. It now appears that he used those methods to carefully select and groom young recruits, but for the Islamic State.