Allah says in the Qur’an:
“Say: O ‘Ibaadi (My slaves) who have transgressed against themselves (by committing evil deeds and sins)! Despair not of the Mercy of Allah, verily, Allah forgives all sins. Truly, He is Oft‑Forgiving, Most Merciful”
(al-Zumar 39:53)
The Prophet (peace be upon him) said: “Allah will accept the repentance of His slave so long as the death rattle has not reached his throat.” (Ahmad, At Tirmidhi 3537)
i.e., so long as the soul has not reached the throat. Every sin from which a man repents, Allah will accept his repentance.
Anas ibn Malik (may Allah be pleased with him) narrated: I heard the Messenger of Allah (peace be upon him) say: Allah, Blessed and Exalted, says, “O son of Adam! However much you call upon Me and place your hopes in Me, I will forgive you without any reservation. O son of Adam! If you have sins piling up to the clouds and then ask My forgiveness, I will forgive you without any reservation. O son of Adam! If you come to me with enough mistakes to fill the Earth, and meet Me without associating anything as a partner with Me, I will come to you with enough forgiveness to fill the Earth.”
(Sunan At-Tirmidhi, Book 45, Number 3540, graded as Hasan)
Narrated Harith ibn Suwaid: “I went to see ‘Abdullah to inquire about his health as he was sick and he narrated to us a hadith of Allah’s Messenger (peace be upon him). He heard Allah’s Messenger (peace be upon him) as saying:
'Allah is more pleased with the repentance of His believing servant than a person who loses his riding beast carrying food and drink. He sleeps (being disappointed of its recovery) and then gets up and goes in search for that, until he is stricken with thirst, then comes back to the place where he had been before and goes to sleep completely exhausted placing his head upon his hands waiting for death. And when he gets up, lo there is before him his riding beast and his provisions of food and drink. Allah is more pleased with the repentance of His servant than the recovery of this riding beast along with the provisions (of food and drink).’”
(Sahih Muslim, Book 51, Hadith 7131)
The main steps of tawbah (repentance) to mean are the following:
(i) immediate renunciation of the sin,
(ii) firm intention and determination to not return to the sin ever again,
(iii) regret over having committed a sin,
(and if the sin was against the rights of another human being, then one must also compensate for it).
Some du’aas:
لَّا إِلَهَ إِلَّا أَنتَ سُبْحَانَكَ إِنِّي كُنتُ مِنَ الظَّالِمِينَ
La illaha illa Anta Subhanaka, inni kuntu min adh-dhalimeen
There is no God but You; Glory be to You, Truly I have been one of the wrongdoers. (Surah al-Anbiyah, 21: 87)
Sa’d ibn Waqas (radiAllahu anhu) reported that the Prophet (salAllahu allayhi wasalam) said, “The supplication made by the Companion of the Fish (Prophet Yunus (as)) in the belly of the fish was (the above). If any Muslim supplicates in these words, his supplication will be accepted/responded to.”
In another report we read, “I know words that will cause Allah to remove one’s distress. These are the words (of supplication) of my brother Yunus, peace be upon him”
(at-Tirmidhi; 3500, an-Nisa’i in `Amal al-yawmi wa al-layla; #656, al-Hakim 1:505 and 2:383. The latter declared it sound (sahih) and Dhahabi confirmed him)
اللَّهُمَّ أَنْتَ رَبِّي لا إِلَهَ إِلا أَنْتَ خَلَقْتَنِي وَأَنَا عَبْدُكَ وَأَنَا عَلَى عَهْدِكَ وَوَعْدِكَمَا اسْتَطَعْتُ أَعُوذُ بِكَ مِنْ شَرِّ مَا صَنَعْتُ أَبُوءُ لَكَ بِنِعْمَتِكَ عَلَيَّ وَأَبُوءُ لَكَ بِذَنْبِي فَاغْفِرْ لِي فَإِنَّهُ لا يَغْفِرُ الذُّنُوبَ إِلا أَنْتَ
Allahumma anta Rabbi la ilaha illa anta, Anta Khalaqtani wa ana abduka, wa ana ‘ala ahdika wa wa’dika mastata’tu, A’udhu bika min Sharri ma sana’tu, abu’u Laka bini’matika ‘alaiya, wa Abu Laka bidhanbi faghfirli innahu la yaghfiru adhdhunuba illa anta
O Allah! You are my Lord! None has the right to be worshipped but You. You created me and I am Your slave, and I am faithful to my covenant and my promise as much as I can. I seek refuge with You from all the evil I have done. I acknowledge before You all the blessings You have bestowed upon me, and I confess to You all my sins. So I entreat You to forgive my sins, for nobody can forgive sins except You.
Shaddad ibn Aws (radiAllahu anhu) relates that the Prophet (salAllahu alayhi wasalam) said that the most superior way of asking for forgiveness from Allah is to say (the above du’aa). That “If somebody recites it during the day with firm faith in it, and dies on the same day before the evening, he will be from the people of Paradise; and if somebody recites it at night with firm faith in it, and dies before the morning, he will be from the people of Paradise.”
(Sahih al-Bukhari; 8,75,318, at-Tirmidhi; 3393, an-Nasa’i; 5522, Ahmad; 16662)
اللَّهُمَّ اعْفِرْلِى ذَنْبِئ كُلَّهُ، و جِلَّهُ، وَ أوَّلَهُ وَ آخِرَهُ عَلا نِيَتَهُ وَ سِرَّهُ
Allahumma-ghfir li dhanbi kullahu, diqqahu wa jillahu, wa awwalahu wa akhirahu, wa ‘ala niyatahu wa sirrahu
O Allah! Forgive me all my sins, great and small, the first and the last, those that are apparent and those that are hidden.
(Muslim 1:350)