Imam al-Shafi'i (may Allah have mercy on him) said: "Because the saying of the Messenger of Allah (peace and blessings be upon him), 'Take (this ruling) from me; Allah Almighty has appointed a way for them (the women who commit adultery),' is the first (ruling) that was revealed, by which (the punishment of) confinement and harm was abrogated for the man and woman who commit adultery. Then, when the Prophet (peace and blessings be upon him) stoned Sayyiduna Ma'iz (may Allah be pleased with him) and did not flog him, and ordered Sayyiduna Unays (may Allah be pleased with him) to go in the morning to the other man's wife and, if she confessed, to stone her, this indicates that (the punishment of) flogging was abrogated for the free, married man and woman who commit adultery, and that (the punishment of) stoning remained established for them both."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحدود / Q16915