The Messenger of Allah ﷺ said, "Legal punishments are not to be carried out in the mosques, nor is retaliation to be exacted in them."
حدثنا وكيع حدثنا محمد بن عبد الله الشعيثي عن العباس بن عبد الرحمن المدني
قال رسول الله ﷺ لا تقام الحدود في المساجد ولا يستقاد فيها
Its isnad is daif, due to the unknown status of Abbas bin Abdul-Rahman or Qasim bin Abdul-Rahman, and there occurred in it a major confusion in its chain. In the Musnad it reads, "Muhammad bin Abdullah Shuaythi," while in the Musnad (Dar al-Fikr edition) 6/5351 it reads, "Muhammad bin Abdullah, from Shaybi," which is a distortion arising from lack of familiarity with the chains of transmission. But he is actually Muhammad bin Abdullah bin Muhajir Shuaythi, who is well known among the men of Taqrib, and he is truthful, from the seventh generation.As for the second confusion, Ibn Hajar pointed it out in Tajil, in the biographical entry of Abbas bin Abdul-Rahman, where he said, "He is actually Qasim bin Abdul-Rahman Muzani," and said, "This is a gross error." However, it should be noted against Ibn Hajar that he did not provide a biographical entry for Qasim bin Abdul-Rahman Muzani, given that he is not unknown.The hadith was narrated by Ibn Abu Shayba, 10/42, number 8696, Hind edition, in the chapter on legal punishments, and by Tirmidhi, 4/19, number 1401, in the chapter on blood money, under "What has been said about a man who kills his son," through another route from Ibn Abbas. Likewise Ibn Majah, 2/867, number 2599, and Bayhaqi, 8/328. The hadith is hasan, see what follows it.