Short answer
To repent (make tawbah), stop the sin, feel real regret, and resolve sincerely not to return to it. If the sin wronged a person, also return their right or ask their pardon. Then ask Allah's forgiveness. Allah accepts repentance until the moment of death and until the sun rises from the west.
Repentance from every sin is fard, and it is due straight away, not later. Its conditions are leaving the sin, regret, and a firm resolve not to return; for rights of people, returning the right or gaining pardon; and for missed duties such as prayer, fasting or zakat, making them up.
The four schools agree on this.
Explanation
Tawbah means turning back to Allah. The Prophet ﷺ said: "Regret is repentance." Regret is the heart of it, and scholars list the conditions that make it real:
- Stop the sin now, not after one last time.
- Regret it sincerely, because it displeased Allah.
- Resolve firmly not to go back to it.
- Put right what you can. If you took money, return it. If you hurt someone's honour, seek their pardon if that will not cause more harm. If you missed prayers or fasts, make them up (qada). If you did not pay zakat, pay it.
Then ask Allah's forgiveness in your own words or with the Quranic and prophetic duas, such as astaghfirullah wa atubu ilayh (I seek Allah's forgiveness and turn to Him). A sunnah prayer helps: the Prophet ﷺ said that whoever commits a sin, makes wudu well, prays two rak'ahs and asks Allah's forgiveness will be forgiven. This is Salat al-Tawbah.
You do not need to confess to anyone. Islam has no confession to a priest, and Muslims are told to cover their own sins, not announce them. Repentance has a deadline: it is accepted until the death rattle and until the sun rises from the west. And it is generous: Allah replaces the evil deeds of those who repent, believe and do good with good deeds (25:70). If you slip again, repent again; see repeating the same sin.
The evidence
Quran, Surah At-Tahrim 66:8
يَٰٓأَيُّهَا ٱلَّذِينَ ءَامَنُوا۟ تُوبُوٓا۟ إِلَى ٱللَّهِ تَوْبَةًۭ نَّصُوحًا عَسَىٰ رَبُّكُمْ أَن يُكَفِّرَ عَنكُمْ سَيِّـَٔاتِكُمْ وَيُدْخِلَكُمْ جَنَّٰتٍۢ تَجْرِى مِن تَحْتِهَا ٱلْأَنْهَٰرُ يَوْمَ لَا يُخْزِى ٱللَّهُ ٱلنَّبِىَّ وَٱلَّذِينَ ءَامَنُوا۟ مَعَهُۥ ۖ نُورُهُمْ يَسْعَىٰ بَيْنَ أَيْدِيهِمْ وَبِأَيْمَٰنِهِمْ يَقُولُونَ رَبَّنَآ أَتْمِمْ لَنَا نُورَنَا وَٱغْفِرْ لَنَآ ۖ إِنَّكَ عَلَىٰ كُلِّ شَىْءٍۢ قَدِيرٌۭ ﴿٨﴾
O you who have believed, repent to Allah with sincere repentance. Perhaps your Lord will remove from you your misdeeds and admit you into gardens beneath which rivers flow [on] the Day when Allah will not disgrace the Prophet and those who believed with him. Their light will proceed before them and on their right; they will say, "Our Lord, perfect for us our light and forgive us. Indeed, You are over all things competent."
Commands sincere repentance and promises forgiveness.
Quran, Surah Az-Zumar 39:53
۞ قُلْ يَٰعِبَادِىَ ٱلَّذِينَ أَسْرَفُوا۟ عَلَىٰٓ أَنفُسِهِمْ لَا تَقْنَطُوا۟ مِن رَّحْمَةِ ٱللَّهِ ۚ إِنَّ ٱللَّهَ يَغْفِرُ ٱلذُّنُوبَ جَمِيعًا ۚ إِنَّهُۥ هُوَ ٱلْغَفُورُ ٱلرَّحِيمُ ﴿٥٣﴾
Say, "O My servants who have transgressed against themselves [by sinning], do not despair of the mercy of Allah. Indeed, Allah forgives all sins. Indeed, it is He who is the Forgiving, the Merciful."
No sin is too big to repent from.
Quran, Surah Al-Furqaan 25:70
إِلَّا مَن تَابَ وَءَامَنَ وَعَمِلَ عَمَلًۭا صَٰلِحًۭا فَأُو۟لَٰٓئِكَ يُبَدِّلُ ٱللَّهُ سَيِّـَٔاتِهِمْ حَسَنَٰتٍۢ ۗ وَكَانَ ٱللَّهُ غَفُورًۭا رَّحِيمًۭا ﴿٧٠﴾
Except for those who repent, believe and do righteous work. For them Allah will replace their evil deeds with good. And ever is Allah Forgiving and Merciful.
Repentance can turn past sins into good deeds.
Sunan Ibn Majah 4252
Graded sahih... يَقُولُ النَّدَمُ تَوْبَةٌ ...
"Regret is repentance."
Regret is the core of tawbah.
Sunan Abi Dawud 1521
Graded sahih... مَا مِنْ عَبْدٍ يُذْنِبُ ذَنْبًا فَيُحْسِنُ الطُّهُورَ ثُمَّ يَقُومُ فَيُصَلِّي رَكْعَتَيْنِ ...
"No servant commits a sin, then makes wudu well, stands and prays two rak'ahs and asks Allah's forgiveness, except that Allah forgives him."
The basis of the prayer of repentance.
Sahih Muslim 2703
Sahih... مَنْ تَابَ قَبْلَ أَنْ تَطْلُعَ الشَّمْسُ مِنْ مَغْرِبِهَا تَابَ اللَّهُ عَلَيْهِ ...
"Whoever repents before the sun rises from the west, Allah accepts his repentance."
Repentance stays open until that sign of the Hour.
Jami' at-Tirmidhi 3537
Graded hasan... إِنَّ اللَّهَ يَقْبَلُ تَوْبَةَ الْعَبْدِ مَا لَمْ يُغَرْغِرْ ...
"Allah accepts the repentance of His servant as long as the death rattle has not reached his throat."
Repentance is accepted until the moment of death.
Where the ruling is recorded
- Sharh al-Fiqh al-Akbar (Mulla Ali al-Qari), Section on repentance. Sets out the conditions of repentance and that it is due at once.
- Riyad al-Salihin (al-Nawawi), Chapter on repentance. Lists the three conditions of tawbah and the fourth for rights of people.
This answer is pending review by the scholars on our team. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.