Surah At-Tawbah 9:17
مَا كَانَ لِلْمُشْرِكِينَ أَن يَعْمُرُوا۟ مَسَـٰجِدَ ٱللَّهِ شَـٰهِدِينَ عَلَىٰٓ أَنفُسِهِم بِٱلْكُفْرِ ۚ أُو۟لَـٰٓئِكَ حَبِطَتْ أَعْمَـٰلُهُمْ وَفِى ٱلنَّارِ هُمْ خَـٰلِدُونَ
It is not for the polytheists to maintain the mosques of Allāh [while] witnessing against themselves with disbelief. [For] those, their deeds have become worthless, and in the Fire they will abide eternally.
Translation: Saheeh International
Tafsir
It is not for the idolaters to attend God’s places of worship masājid is also read in the singular masjid entering them or sitting in them bearing witness against themselves to unbelief; those their works have failed their works are invalid and in the Fire they shall abide.
Excerpt from Tafsir al-Jalalayn, commentary on 9:17, via Quran.com. The reader has the full commentary and 9 more tafsirs.