The Iranian news agency Fars reported this news, citing the diplomatic sources in Ankara.
According to Fars, the Russian Defense Ministry sent information about the impending coup the Turkish intelligence. The Russian military, in turn, learned about the coup from the interception of the Turkish military talks. After deciphering it became clear that a few hours later the army would tried to overthrow the government
Full article: Russian military saved Erdogan from coup, media reports (Vestnik Kavkaza)