As-Sa'ib b. Yazid said that when he was sleeping in the mosque a man threw a pebble at him, and when he looked he saw that it was ‘Umar b. al-Khattab, who said, “Go and bring me these two men.” He brought them and ‘Umar asked them what tribe they belonged to, or what place they came from. On their replying that they belonged to at-Ta’if, he said, “If you had belonged to Medina I would have given you a beating for raising your voices in the mosque of God’s Messenger.
Al-Hasan reported in mursal form that God's Messenger said, “A time is coming when people will talk in their mosques about their worldly affairs, so do not sit with them, for God has nothing to do with them.”
Malik said that ‘Umar built a courtyard called al-Butaiha’ in the neighbourhood of the mosque and said, “If anyone wants to make a noise, or recite poetry, or raise his voice, he must go out to this courtyard.”
Abu Huraira said that he heard God’s Messenger say, “If anyone comes to this mosque of mine, coming only for some good which he will learn or teach, he ranks a mujahid in God’s path; but if anyone comes for some other purpose, he ranks as a man who looks at another’s property.”
Ibn Majah and Baihaqi, in Shu'ab al-iman, transmitted it.