Turkey President Recep Tayipp Erdoğan allegedly planned to oust opposition elements from government positions before last July's failed coup attempt, according to secret EU intelligence reports.

The secret intelligence, seen by the Times, contradicts the Turkish government's version of events, especially that Fethullah Gülen, an exiled cleric, was behind the plot.

Erdoğan and his loyalists purged over 100,000 military officials, police officers, judges and governors and arrested over 30,000 in the weeks following the coup. However, the intelligence documents suggest the coup was initiated as a last-ditch attempt to avert the purges as word about their imminence filtered through levels of government.

"The decision to launch the coup resulted from the fears of an incoming purge," said the report, dated 24 August 2016.

"It is likely that a group of officers comprising Gülenists, Kemalists [secularists], opponents of the AKP [Erdoğan's party] and opportunists was behind the coup. It is unlikely that Gülen himself played a role in the attempt."

"The coup was just a catalyst for the crackdown prepared in advance."

The report prepared by Intcen, the EU intelligence centre, does offer a portrayal of Turkey similar to the picture painted by Erdoğan, however.

It states Gülen's followers spent decades placing their supporters in senior positions in the police, judiciary and other institutions, building a network that, according to EU intelligence sources, enabled him to "influence the situation in the country and control the activities of President Erdoğan".

That situation, however, "changed" after Erdoğan began purges of the police and state administration in 2014 that weakened the Gülenists as well as Kemalists and civil activists.

"It is unlikely Gülen really had the abilities and capacities to take such steps," the report said.

"There is no evidence that the army, [which] considers itself as the guardian of Turkey as a secular state, and the Gülenists were willing to co-operate with each other to oust Erdoğan.

"The Gülen movement is very disconnected and somewhat distant from the secular opposition and Turkish army."

The report additionally stated: "Erdoğan exploited the failed coup and the state of emergency to launch an extensive repressive campaign against the opponents of the AKP establishment.

"The huge wave of arrests was already previously prepared."