Narated By Wa’il ibn Hujr : When a woman went out in the time of the Prophet (PBUH) for prayer, a man attacked her and overpowered (raped) her.
She shouted and he went off, and when a man came by, she said: That (man) did such and such to me. And when a company of the Emigrants came by, she said: That man did such and such to me. They went and seized the man whom they thought had had intercourse with her and brought him to her.
She said: Yes, this is he. Then they brought him to the Apostle of Allah (PBUH).
When he (the Prophet) was about to pass sentence, the man who (actually) had assaulted her stood up and said: Apostle of Allah, I am the man who did it to her.
He (the Prophet) said to her: Go away, for Allah has forgiven you. But he told the man some good words (AbuDawud said: meaning the man who was seized), and of the man who had had intercourse with her, he said: Stone him to death.
He also said: He has repented to such an extent that if the people of Medina had repented similarly, it would have been accepted from them.