Praise be to Allaah.
There are proven reports in the Sunnah which indicate that the devils do enter the mosques, because they go into the gaps in the rows and whisper (waswaas) to the individual when he is praying so as to distract him and rob him of proper focus (khushoo).
Abu Dawood (667)and Ahmad (27552) narrated, in a report that was classed as saheeh by al-Albaani in al-Mishkaat (1093), from Anas ibn Maalik (may Allah be pleased with him) that the Messenger of Allah (blessings and peace of Allah be upon him) said: Consolidate your rows, make them close together and stand with your necks in line with one another, for by the One in Whose hand is my soul, I see the devils going into the gaps in the rows as if they are little lambs.
Muslim narrated in his Saheeh (2203) from Abu'l-Alaa' that Uthmaan ibn Abi'l-Aas came to the Prophet (blessings and peace of Allah be upon him) and said: O Messenger of Allaah, the shaytaan interferes between me and my prayer and my recitation, and he makes me confused. The Messenger of Allaah (blessings and peace of Allah be upon him) said: That is a devil called Khinzab. If you feel that, then seek refuge with Allaah from him and spit drily to your left three times. He said: I did that and Allaah took him away from me.
Muslim also narrated (542) that Abu'd-Darda' said: The Messenger of Allaah (blessings and peace of Allah be upon him) stood up (to pray) and we heard him saying: I seek refuge with Allaah from you. Then he said: I curse you with the curse of Allaah three times, and he stretched out his hand as if to take something. When he had finished praying, we said: O Messenger of Allaah, we heard you say something during the prayer that we have not heard you say before, and we saw you stretch out your hand. He said: The enemy of Allaah, Iblees, came with a brand of fire to throw it in my faceâ¦
Al-Bukhaari, Muslim and others narrated from Abu Hurayrah that the Messenger of Allah (blessings and peace of Allah be upon him) said: When the call to prayer is given, the Shaytaan runs away breaking wind loudly so that he will not hear the call. Then when the call has ended, he comes but when iqaamah for prayer is given he runs away, then when the iqaamah has ended, he comes back so that he can whisper to the individual, saying: Remember such and such, remember such and such -- about things that he was not thinking about, until he confuses the man and he does not know how many (rakahs) he prayed.
These hadeeths and others clearly indicate that the devils do enter the mosques, but when they hear the adhaan they run away to somewhere where they cannot hear the call, then they come back after that and distract a person from his prayer and recitation.
And Allah knows best.