Allah says in the Qur’an: “Say: ‘O my Servants who have transgressed against their souls! Despair not of the Mercy of Allah: for Allah forgives all sins: for He is Oft-Forgiving, Most Merciful.'” (Az-Zumar: 53) “Allah accepts the repentance of those who do evil in ignorance and repent soon afterwards; to them will Allah turn in mercy: For Allah is full of knowledge and wisdom.” (An-Nisa’: 17)
Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states: “As a muslim, If you had extra martial affairs with the person you married and then you both repented sincerely for your heinous sin, then you will be forgiven.
Allah says, “Didn’t they know that it is Allah who accepts repentance of His servants and forgives sins?” (At-Tawbah: 104). The Prophet (peace and blessings be upon him) said, “Allah accepts the repentance of a person as long as death has not reached his collar bone (i.e., as long as it is not done in the last pangs of death ).”
Sincere repentance, however, is not simply saying, “Lord, forgive me”, “I ask forgiveness of Allah.” Sincere repentance involves experiencing within oneself a profound sense of guilt for having disobeyed Allah and for the terrible sin one has committed. Secondly, one should totally refrain from approaching that sin as well as from such associations and circumstances that may led him/her to it; thirdly, one must be resolved never to repeat the same in the future, and finally, one must also do whatever he/she can to wipe out the past sins by engaging in good works as much as possible.
Once the above procedures are followed, we can look forward to Allah’s forgiveness for He is certainly All-Merciful and All-Forgiving.
Having said this, it is important to point out that if a person has sinned in the past, he/she must continue to be vigilant, and remember that Allah Sees all that we do. The person should try to visualize heaven and hell as if they are in front of them. That is the only way to check one’s carnal desires .”