Sahih Muslim | Book 37 | Chapter 5

Narrated by Abu Huraira
Abu Huraira reported from Allah's Messenger (may peace be upon him) that his Lord, the Exalted and Glorious, thus said. A servant committed a sin and he said: O Allah, forgive me my sins, and Allah (the Exalted and Glorious)said:My servant committed a sin and then he came to realise that he has a Lord Who forgives the sins and takes to account (the sinner) for the sin. He then again committed a sin and said: My Lord, forgive me my sin, and Allah, the Exalted and High, said: My servant committed a sin and then came to realise that he has a Lord Who would forgive his sin or would take (him) to account for the sin. He again committed a sin and said: My Lord, forgive me for my sin, and Allah (the Exalted and High) said: My servant has committed a sin and then came to realise that he has a Lord Who forgives the sins or takes (him) to account for sin. O servant, do what you like. I have granted you forgiveness.

'Abd al-A'la said: I do not know whether he said thrice or four times to do "what you desire". The hadith has been narrated on the authority of 'Abd al-A'la b. Hammad with the same chain of transmitters.

Narrated by Abu Huraira
Abu Huraira reported lie heard Allah's Messenger (may peace be upon him) as saying that a servant committed a sin. The rest of the hadith is the same, but there is a slight variation of wording.

Narrated by Abu Mu'sa
Abu Mu'sa reported Allah's Messenger (may peace be upon him) as saying that Allah, the Exalted and Glorious, Stretches out His Hand during the night so that the people repent for the fault committed from dawn till dusk and He stretches out His Hand daring the day so that the people may reprint for the fault committed from dusk to dawn. (He would accept repentance) before the sun rises in the west (before the Day of Resurrection). A hadith like this has been narrated on the authority of Shu'ba with the same chain of transmitters.