Turkey intercepted encrypted messages sent by followers of US-based Fethullah Gulen well before the July 15 coup attempt, giving Ankara names of tens of thousands within the preacher's network, a senior official said on Saturday.
Turkey says Gulen masterminded the failed coup from his compound in Pennsylvania, using followers in Turkey who for years had built up a top-level presence within state institutions.
The reclusive preacher denies the charges.
The Turkish official, speaking to reporters on condition of anonymity due to the sensitivity of the information, said Turkey's national intelligence organisation began decrypting messages sent on the app ByLock in May last year.
Almost 40,000 names of Gulen followers, including 600 ranking military personnel, were identified by Turkish intelligence through the intercepted messages.
The official added that "a large number of people identified via ByLock were directly involved in the coup attempt".
The official said that since December 2013, Gulen followers used encrypted messaging apps to communicate securely, and had started using ByLock in 2014. A corruption scandal erupted in December 2013 that Erdogan blamed on Gulen and which represented one of the most serious challenges to his rule.
"The ByLock data made it possible for us to map their network, at least a large part of it. They (later) switched to another app when they realised that ByLock was compromised," said the official.
Turkish officials have said that by the time of the coup the plotters were communicating via the better-known messaging service WhatsApp.
Turkish energy minister Berat Albayrak said this week that Ankara had already prepared lists of suspected Gulenists in major institutions before the coup and had been planning a major purge this summer.
Analysts had said the speed of the crackdown after the coup that has seen some 18,000 detained suggests the authorities were preparing a swoop and knew who to target.
But the government has also admitted there were intelligence weaknesses leading up to the coup.
Reports have suggested that Turkish intelligence got wind of the plot hours before it happened but did not inform politicians. There has been speculation that the powerful head of the intelligence organisation, Hakan Fidan, will have to resign, but so far he has kept his job.