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:107

And ˹there are˺ those ˹hypocrites˺ who took for themselves a mosque for causing harm and disbelief and division among the believers and as a station for whoever had warred against Allah and His Messenger before. And they will surely swear, "We intended only the best." And Allah testifies that indeed they are liars.  

And, among them, those who have chosen a mosque — these were twelve men from among the hypocrites — by way of harm, to cause distress for those of the mosque of Qubā’, and disbelief, since they built it on the orders of the monk Abū ‘Āmir, as a sanctuary for him, so that whoever comes from his side may stay there: he had gone to the Byzantine Emperor (qaysar) to bring troops to fight against the Prophet (s), and to cause division among the believers, who pray in the mosque of Qubā’, by having some of these pray in their ˹the hypocrites’˺ mosque, and as an outpost, an observation post, for those who waged war against God and His Messenger before, that is, before it was built — meaning the above-mentioned Abū ‘Āmir — they will swear: ‘We desired nothing, by building it, but, to do, good’, by way of kindness towards the poor in times of ˹heavy˺ rain or ˹extreme˺ heat and in order to provide ˹a place of worship˺ for the Muslims; and God bears witness that they are truly liars, in this ˹claim of theirs˺. They had asked the Prophet (s) to perform prayers in it, and so the following was revealed:
القرآن:٩:١٠٧

وَالَّذِينَ اتَّخَذُوا مَسْجِدًا ضِرَارًا وَكُفْرًا وَتَفْرِيقًا بَيْنَ الْمُؤْمِنِينَ وَإِرْصَادًا لِمَنْ حَارَبَ اللَّهَ وَرَسُولَهُ مِنْ قَبْلُ ۚ وَلَيَحْلِفُنَّ إِنْ أَرَدْنَا إِلَّا الْحُسْنَىٰ ۖ وَاللَّهُ يَشْهَدُ إِنَّهُمْ لَكَاذِبُونَ  

{و} منهم {الذين اتخذوا مسجدا} وهم اثنا عشر من المنافقين {ضرارا} مضارة لأهل مسجد قباء {وكفرا} لأنهم بنوه بأمر أبي عامر الراهب ليكون معقلا له يقدم فيه من يأتي من عنده وكان ذهب ليأتي بجنود من قيصر لقتال النبي ﷺ {وتفريقا بين المؤمنين} الذين يصلون بقباء بصلاة بعضهم في مسجدهم {وإرصادا} ترقبا {لمن حارب الله ورسوله من قبل} أي قبل بنائه، وهو أبو عامر المذكور {وليحلفن إن} ما {أردنا} ببنائه {إلا} الفعلة {الحسنى} من الرفق بالمسكين في المطر والحر والتوسعة على المسلمين {والله يشهد إنهم لكاذبون} في ذلك، وكانوا سألوا النبي ﷺ أن يصلي فيه فنزل.