The Messenger of Allah ﷺ forbade buying and selling in the mosque, announcing lost property in it, and reciting poetry in it. He also forbade gathering in circles before the prayer on Friday.
أن رسول الله ﷺ نهي عن الشراء والبيع في المسجد، وأن تنشد فيه ضالة، وأن ينشد فيه شعر، ونهي عن التحلق قبل الصلاة يوم الجمعة.
It was narrated by Abu Dawud (1079), Tirmidhi (322), Nasai (716), and Ibn Majah (749), and Ibn Khuzayma (1306) graded it sahih, all of them through routes from Muhammad bin Ajlan, from Amr bin Shuayb with his chain, in similar wording. Its chain of transmission is hasan because of Amr bin Shuayb, for he is hasan al-hadith.On this subject there is also what was narrated from Abu Hurairah as a raised report, "If you see someone selling or buying in the masjid, say, 'May Allah not make your trade profitable,' and if you see someone announcing a lost item in it, say, 'May Allah not return it to you.'" This was narrated by Tirmidhi (1321), Ibn Khuzayma (1305), Ibn Hibban (1650), and Hakim (2/56), all of them through routes from Abdul-Aziz bin Muhammad, who said, Yazid bin Khusayfa informed us, from Muhammad bin Abdul-Rahman bin Thawban, from Abu Hurairah. And he related it.Tirmidhi said, "Hasan gharib." I say, it is as he said, for Abdul-Aziz bin Muhammad, who is Darawardi, is a subject of disagreement among scholars, though he is truthful. There has been disagreement over whether his transmission of this hadith is connected or has a broken chain at the end.Arim, who is Muhammad bin Fadl, and Saeed bin Sulayman, narrated it from Darawardi, from Yazid bin Khusayfa, from Muhammad bin Abdul-Rahman bin Thawban, from Abu Hurairah, as a connected chain. Yaqub Dawraqi and Ibn Abu Mathur narrated it from Darawardi, from Yazid bin Khusayfa, from Muhammad bin Abdul-Rahman bin Thawban, who said, "I do not know it except from Abu Hurairah." Thus it is transmitted with doubt regarding Abu Hurairah. Saeed bin Mansur and Abdul-Ala bin Hammad narrated it from Darawardi with a chain having a broken end.Thawri also narrated it from Yazid bin Khusayfa, and there was disagreement over his transmission as well. Sayf bin Muhammad narrated it from Thawri, from Yazid bin Khusayfa, from Ibn Thawban, from his father, as a connected chain. Abdul-Rahman bin Mahdi differed with him, narrating it from Thawri, from Yazid bin Khusayfa, from Ibn Thawban, with a chain having a broken end. The correct view is with him, given the strength of his transmission and the disagreement that occurred over Darawardi's version. For this reason, Daraqutni gave preference to the view that the chain has a broken end. See Ilal (10/65).Tirmidhi said, "Some scholars have disliked buying and selling in the masjid, and this is the view held by Ahmad and Ishaq. It has also been narrated from some scholars among the Followers that they permitted buying and selling in the masjid."However, there is consensus that if someone sells something in the masjid, the sale is valid, since the conditions of sale contracts are fulfilled, but the blessing is removed from it because of the Prophet's ﷺ supplication against it.