Whether Mr. Zaharan found the Islamic State or the Islamic State found him, they seemed inextricably drawn to each other. In other places, like Indonesia and the Philippines, the Islamic State has been adept at taking Islamic radicals with local grievances and enlisting them in the global slipstream of terror.

By 2017, Mr. Zaharan and his followers were targeting a Sufi sect in Kattankudy, accusing its members of being infidels, even though Sufis are fellow Muslims who practice a mystical form of the faith. After the Sufis in Kattankudy handed out packets of rice to the poor, an action that Mr. Zaharan regarded as trying to buy hungry converts, he grabbed a sword and charged the crowd.

The police said they tried to arrest Mr. Zaharan and one of his brothers, but they escaped.

About 10 of his followers were detained, however, including his father and other relatives. Surprisingly for a small group from a distant part of Sri Lanka, the detained members of National Thowheeth Jama’ath managed to get a high-profile lawyer from Colombo to represent them.

H.M. Ameer, a member of the Sufi community, said that he and other Sufis had repeatedly contacted the police to warn about Mr. Zaharan’s extremism. They sent a thick file to Colombo. But there was little result, Mr. Ameer said. His assessment echoed complaints from recent days that Sri Lankan authorities failed to act on repeated warnings from overseas intelligence agencies about Mr. Zaharan planning a catastrophic attack.

On Thursday, Sufis in Kattankudy received a warning from the Sri Lankan criminal investigation department that their holy places might be targeted on Friday by militants associated with Mr. Zaharan who are still on the run.

Looking out on soldiers guarding the Badhriyyah Jumah Mosque where he and other Sufis worship, Mr. Ameer shook his head.

“We warned them that this man was vehemently spreading Wahhabism and that he was calling for jihad,” he said. “It was out in the open, clear as day. Nothing was done.”