Sayyiduna Anas (may Allah be pleased with him) reports: A woman came to the Prophet (peace and blessings be upon him) and confessed to adultery. She was pregnant, so the Messenger of Allah (peace and blessings be upon him) postponed her punishment until she gave birth. Then he ordered regarding her, so her clothes were tied around her, then he ordered that she be stoned. Then he offered the funeral prayer over her. A man said: O Messenger of Allah! You are praying over her even though she committed adultery and you stoned her. The Prophet (peace and blessings be upon him) said: "She has repented with such a repentance that if seventy people of Madinah were to repent with such repentance, it would be accepted from them. Can you find anything better than that she gave her life out of generosity?"
Related hadith on this topic