Sayyiduna Wa'il bin Hujr (may Allah be pleased with him) relates that in the time of the Messenger of Allah (peace and blessings be upon him) a woman went out (of her home) intending to pray. On the way a man met her and forcibly satisfied his desire with her. The woman cried out and he (the offender) ran off. Then another man passed by her, and the woman said: That man did such-and-such to me. So the people set off and seized the man who she thought had assaulted her, and they asked (her): Is this the one? She said: Yes, this is the one. So they brought him to the Prophet (peace and blessings be upon him). When he (peace and blessings be upon him) ordered that he be stoned, her (actual) assailant, the one who had assaulted her, stood up and said: I am the one. He (peace and blessings be upon him) said: "Come close to me; Allah has forgiven you," and he also spoke kind words to the other man. The people said to him about the man who had assaulted her: Will you stone him? He (peace and blessings be upon him) said: "He has repented with such a repentance that, if (all) the people of Madinah had repented with it, it would have been accepted from them."
Hadith Referenceالمعجم الكبير للطبراني / باب الواو / 18239