Allah commands His servants to single Him out alone for worship and that none should be supplicated to along with Him, nor should any partners be associated with Him. As Qatadah said concerning Allah's statement,
(And the Masjids are for Allah, so invoke not anyone along with Allah.) "Whenever the Jews and Christians used to enter their churches and synagogues, they would associate partners with Allah. Thus, Allah commanded His Prophet to tell them that they should single Him out alone for worship." Ibn Jarir recorded from Sa`id bin Jubayr that he said concerning this verse,
وَأَنَّ الْمَسَاجِدَ لِلَّـهِ فَلَا تَدْعُوا مَعَ اللَّـهِ أَحَدًا (...and that masajid (mosques) belong to Allah; so, do not invoke anyone along with Allah....72:18). The word masajid is the plural of masjid. Here the word could be taken in its popular sense, that is, mosques or places of worship dedicated for the performance of prayers. In this case, it would mean that all mosques belong to Allah, dedicated to His sole worship and therefore we are not permitted to call on anyone else besides Allah, like the Jews and Christians commit shirk in their places of worship. In sum, the mosques must be kept clear of all false beliefs and vile deeds.
The word masajid could also have another sense. It could be the plural of masjad, with the letter jim carrying fath, in which case it would be masdar mimi 'infinitivity' and mean 'to prostrate or prostration'. The verse in this sense would signify that worship is reserved exclusively for Allah. It is not permitted to prostrate to anyone, because if he calls on anyone else for help, it is as though he is prostrating to him which must be avoided.
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 15–22
The jinn who heard the Quran not only accepted it immediately, but also became its propagators. This shows that whenever a true discourse reaches the ears of living people, it creates a two-fold effect—first, an open-hearted admission of its truth and second, a willingness to propagate its teachings.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.