It is narrated from Sayyiduna Zayd bin Khalid al-Juhani and Sayyiduna Abu Hurayrah (may Allah be pleased with them both) that two men came to the Messenger of Allah (peace and blessings be upon him) with their dispute. One of them said: O Messenger of Allah! Judge between us according to the Book of Allah. The other, who had more understanding of the two, said: Yes, judge between us according to the Book of Allah, and permit me to speak. He said: "Speak." He said: My son was a hired worker for this man, and he committed adultery with his wife. I was told that stoning was due upon my son, so I ransomed him from it with a hundred sheep and a slave girl of mine. Then I asked the people of knowledge, and they told me that upon my son are only a hundred lashes and exile for a year, while stoning is due upon his wife. The Messenger of Allah (peace and blessings be upon him) said: "By the One in whose hand is my soul! I shall judge between you two only according to the Book of Allah: your sheep and your slave girl are returned to you." And he had his son given a hundred lashes and exiled him for a year, and he ordered Unays al-Aslami to stone the other man's wife if she confessed. She confessed, so he stoned her.
Hadith Referenceالمعجم الكبير للطبراني / باب الزاي / 5176