The verse "And those who took a masjid for causing harm" [Tawbah 9:107] refers to some people from the Ansar who built a masjid. Abu Amir had said to them, "Build your masjid, and prepare whatever strength and weapons you can. I am going to Caesar, the king of the Romans, and I will bring back an army of Romans and drive out Muhammad and his companions."
أن قوله: {والذين اتخذوا مسجدا ضرارا} هم أناس من الأنصار، ابتنوا مسجدا، فقال لهم أبو عامر: ابنوا مسجدكم، واستعدوا بما استطعتم من قوة، وسلاح. فإني ذاهب إلى قيصر ملك الروم، فآتي بجند من الروم فأخرج محمدا وأصحابه.
No references are available.
Ibn Abu Hatim narrated it in his Tafsir (6/1878) from his father, from Abu Salih, who said, "Muawiya bin Salih told us, from Ali bin Abu Talha, from Ibn Abbas," and then he related it. Its chain is hasan because of Abu Salih, who is Abdullah bin Salih, the scribe of Layth al-Misri, hasan al-hadith.This Abu Amir was the monk who had converted to Christianity in pre-Islamic times before the arrival of the Prophet ﷺ in Madinah, and he had studied the learning of the People of the Book. When the Messenger of Allah ﷺ came to Madinah, and the Muslims gathered around him, and the word of Islam rose high, he showed his enmity and hatred, and he urged his companions among the people of Madinah to build this masjid next to Masjid Quba, so it would serve as a center for them to consult among themselves. As for him, he went to Syria to seek help against the Prophet ﷺ, and the king of Syria promised him an army and equipment.When they finished building their masjid, they came to the Prophet ﷺ and said, "We have finished building our masjid, and we would love for you to pray in it and pray to Allah for blessing for us." The Prophet ﷺ said, "We are on a journey, but when we return, Allah willing." That is, from Tabuk. When he returned from Tabuk on his way back to Madinah, with only a day or part of a day left before reaching it, revelation came down to him,"Never stand there. A masjid founded on piety from the first day is more worthy for you to stand in. In it are men who love to purify themselves, and Allah loves those who purify themselves" [Tawbah 9:108].So the Messenger of Allah ﷺ sent someone to demolish it.As for His saying, "a masjid founded on piety from the first day", it has been said that this refers to Masjid Quba, as has come in the sahih.