Some people say that the punishment of stoning (Rajm) is doubtful because it is not known whether the Prophet ﷺ gave the ruling of stoning before or after the revelation of the verse of Surah An-Nur:
الزَّانِيَةُ وَالزَّانِي فَاجْلِدُوا كُلَّ وَاحِدٍ مِّنْهُمَا مِائَةَ جَلْدَةٍ
Reference: (Surah An-Nur:2)
Translation: The woman and the man guilty of adultery—flog each one of them with a hundred lashes.
In this verse, the punishment for the adulterer is stated as one hundred lashes without distinction between married and unmarried. So if the Prophet ﷺ implemented stoning before the revelation of Surah An-Nur, then after its revelation, the ruling of stoning would have been abrogated! Similarly, Abu Ishaq Shaybani says: I asked Abdullah bin Abi Awfa (RA) whether the Prophet ﷺ stoned anyone. He said yes. I asked: was it before or after Surah An-Nur? He said: I do not know.
Reference: (Sahih Bukhari:6813)
First Point
Claiming that the punishment of stoning is doubtful is baseless because the fact that some matters remained hidden from a companion does not necessarily mean that other companions were also unaware of it. Rather, a companion saying "I do not know" in response to a question indicates their scholarly integrity and caution, meaning that they denied what they did not know.
Second Point
The punishment of one hundred lashes mentioned in the verse of Surah An-Nur for the adulterous man and woman is general, from which it apparently seems that whether the adulterer is married or unmarried, the punishment for every type of adulterer is one hundred lashes. However, the broad meaning of this verse was specified by the Sunnah of the Prophet, and the Holy Prophet Muhammad (peace be upon him) clarified it through his practice that the punishment for adultery mentioned in Surah An-Nur is only for the unmarried adulterer. If the adulterous man or woman is married, then their punishment is not one hundred lashes, but rather stoning (Rajm).
The Quranic exegete Razi, may Allah have mercy on him, writes: "The majority of the Mujtahids have taken the obligation of stoning for a married adulterer from the fact that it is established through mutawatir (continuous) reports that the Messenger of Allah, peace be upon him, practiced it. Besides this, Abu Bakr, Umar, Ali, Jabir bin Abdullah, Abu Saeed Khudri, Abu Hurairah, Buraidah Aslami, Zaid bin Khalid, and other companions, may Allah be pleased with them, have narrated reports of stoning. Among these narrators, some have also narrated incidents of the stoning of Sayyiduna Mu'adh and the women of Lakhm and Ghamid. Sayyiduna Umar, may Allah be pleased with him, said: 'If it were not for the fear that people would say Umar added to the Book of Allah, I would have recorded this ruling of stoning in the Quran.'"
Reference: Al-Tafsir al-Kabir 305/23
Third Point
The occurrence of the punishment of stoning certainly took place only after the revelation of Surah An-Nur. The evidence for this is that Surah An-Nur contains the account of the incident of Al-Ifk, which happened in the sixth year of Hijrah or before that. See:
Reference: (Sahih Bukhari: 4138, Tafsir Qurtubi: 198/12)
Whereas the incidents in which the punishment of stoning to death (Rajm) is mentioned occurred after Hazrat Abu Huraira رضي الله عنه embraced Islam and after Hazrat Abdullah bin Abbas came to Madinah, and these two personalities are among the eyewitnesses of the incident of Rajm. See:
Reference: Sahih Bukhari (6430), Sahih Muslim (1691), Fath al-Bari (120/12)
Sayyiduna Abu Huraira رضي الله عنه embraced Islam in the year 7 AH, and Sayyiduna Abdullah bin Abbas came to Madinah with his mother in the year 9 AH.
See:
Reference: Tarikh Khalifa bin Khayyat (p.86), Tarikh Ibn Abi Khaythama (2/19, 1525), Al-Isti'ab (4/1771), Siyar A'lam al-Nubala by al-Dhahabi (3/333)
It is understood that even after the revelation of Ayat al-Noor, the Prophet ﷺ implemented the punishment of Rajm.
Fourth Point
If the punishment of stoning had been abrogated, then how would the Companions, especially the Rightly Guided Caliphs, have enforced it?! The fact that the Companions, may Allah be pleased with them all, established the punishment of stoning after the Prophet ﷺ is clear evidence that there was no doubt among them regarding the punishment of stoning and they did not consider it abrogated, as is evident from this narration:
It is narrated from Sayyiduna Abdullah bin Abbas رضي الله عنهما that Sayyiduna Umar bin Khattab رضي الله عنه was sitting on the pulpit of the Prophet ﷺ and said: Indeed, Allah Almighty sent Muhammad ﷺ with the truth and revealed the Book upon you. Among what was revealed to you in the form of the Book of Allah, there was also the verse of stoning (Rajm). We used to read it, understand it, and memorize it. The Messenger of Allah ﷺ himself ordered stoning during his time. Then after you, we also carried out stoning, but I fear that if time continues to pass like this, someone might claim that the verse of stoning is not found in the Book of Allah and thus abandon this obligation which Allah Almighty has revealed. Certainly, the ruling of stoning is established from the Book of Allah for the person who commits adultery after marriage, whether man or woman, provided that the testimony is complete, or pregnancy is evident, or the person confesses themselves.
Reference: (Sahih Bukhari: 6830, Sahih Muslim: 1691)
The punishment of stoning was carried out by the Rightly Guided Caliphs and the noble Companions. For this, see:
Reference: Sharh Sahih al-Bukhari by Ibn Battal (8/431), Al-Muhalla by Ibn Hazm (12/169), and Al-Tamhid by Ibn Abd al-Barr (9/79), Al-Mughni (12/309)
Final Point
It should be remembered that the authority to implement the punishment of whipping is given to the Muslim rulers and heads of state and their deputies, not to everyone.
Ibn Rushd says: (And who should implement the hudood?… There is consensus that the ruler should carry it out, and this applies to all other punishments (Shari'ah hudood) as well).
Reference: Bidayat al-Mujtahid (4/228)