Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:9:18

The mosques of Allah are only to be maintained by those who believe in Allah and the Last Day and establish prayer and give zakah and do not fear except Allah, for it is expected that those will be of the ˹rightly˺ guided.  

Only he shall attend God’s places of worship who believes in God and the Last Day, and observes prayer, and pays the alms, and fears none but God alone; it may be that those will be among the rightly guided.
القرآن:٩:١٨

إِنَّمَا يَعْمُرُ مَسَاجِدَ اللَّهِ مَنْ آمَنَ بِاللَّهِ وَالْيَوْمِ الْآخِرِ وَأَقَامَ الصَّلَاةَ وَآتَى الزَّكَاةَ وَلَمْ يَخْشَ إِلَّا اللَّهَ ۖ فَعَسَىٰ أُولَٰئِكَ أَنْ يَكُونُوا مِنَ الْمُهْتَدِينَ  

{إنما يعمُر مساجد الله من آمن بالله واليوم الآخر وأقام الصلاة وآتى الزكاة ولم يخش} أحدا {إلا الله فعسى أولئك أن يكونوا من المهتدين}.