Two men came to the Messenger of Allah ﷺ with a dispute. One of them said, "Judge between us by the Book of Allah."The other, who was the more knowledgeable of the two, said, "Yes, Messenger of Allah, judge between us by the Book of Allah, and grant me permission to speak."The Prophet ﷺ said, "Speak."He said, "My son was a hired worker for this man, and he committed adultery with his wife. I was told that my son must be stoned, so I ransomed him with a hundred sheep and a Jariya of mine. Then I asked the people of knowledge, and they informed me that my son is to receive a hundred lashes and be banished for a year, and that stoning applies only to the man's wife."The Messenger of Allah ﷺ said, "By the One in whose hand is my soul, I will judge between you by the Book of Allah. As for your sheep and your Jariya, they are to be returned to you."He then had the son given a hundred lashes and banished him for a year, and he ordered Unays to go to the other man's wife, saying, "If she confesses, stone her." She confessed, and he stoned her.
أخبرنا محمد بن سلمة قال أنبأنا عبد الرحمن بن القاسم عن مالك عن ابن شهاب عن عبيد الله بن عبد الله بن عتبة
أن رجلين اختصما إلى رسول الله ﷺ فقال أحدهما اقض بيننا بكتاب الله وقال الآخر وهو أفقههما أجل يا رسول الله وأذن لي في أن أتكلم قال إن ابني كان عسيفا على هذا فزنى بامرأته فأخبروني أن على ابني الرجم فافتديت بمائة شاة وبجارية لي ثم إني سألت أهل العلم فأخبروني أنما على ابني جلد مائة وتغريب عام وإنما الرجم على امرأته فقال رسول الله ﷺ والذي نفسي بيده لأقضين بينكما بكتاب الله أما غنمك وجاريتك فرد إليك وجلد ابنه مائة وغربه عاما وأمر أنيسا أن يأتي امرأة الآخر فإن اعترفت فارجمها فاعترفت فرجمها
Bukhari narrated it in "Oaths and Vows," chapter "How was the oath of the Prophet," hadith 6633 and 6634, from the hadith of Malik. Muslim narrated it in "Punishments," chapter "One who confesses against himself to fornication," hadith 1697, from the hadith of Ibn Shihab Zuhri, with this wording. It is also found in Muwatta (Yahya) 2/822.