Sheikh-ul-Islam ibn Taymiyyah rahimahullaah
Majmoo al-Fataawaa 10/88-90
The Messenger of Allah, sallallahu `alaihi wa sallam, said:
{{The master of invocations for forgiveness is that the servant says:
O' my 'ilâh You are my Lord, there is no 'ilâh but You. You created me, and I am your bondservant, and I will stick to my covenant and promise [of faith and sincere obedience] to You, as to my ability. I seek refuge in You from the evil of what I have done, I acknowledge, to You, your bounties upon me, and I acknowledge, to You, my sin. Thus forgive me, for none forgives sins except You.
Whoever says this as he enters upon evening, then, dies that night, he would enter Paradise; and if one says this as he enters upon morning, then, dies that day, he would enter Paradise.}} (Al-Bukhari)
The servant is always in the blessings of Allah, which necessitate thankfulness, and in sinfulness, which requires seeking forgiveness. Both of these matters are required and essential for the servant at all times, as the servant does not cease to alternate between Allah's (various) favours and blessings, and does not cease to be in need of repentance and seeking forgiveness.
This is why the Master of the Children of Adam, and the Leader of the Pious, Muhammad, (sallallahu alaihi wa sallam) sought forgiveness in all circumstances. He said in an authentic Hadith reported by al-Bukhari:
{{O people repent to your Lord, for verily I seek forgiveness from Allah and repent to him more than seventy times in a day.}} (Bukhari)
It is reported in Saheeh Muslim that he said: {{I seek forgiveness one hundred times in a day.}} (Muslim)
`Abdullah ibn `Umar said: We counted in a single sitting the Messenger of Allah, (sallallahu `alaihi wa sallam), saying one hundred times:
{{My Lord, forgive me and accept my repentance, verily you are Acceptor of Repentance, Oft-Forgiving.}} (Ahmad, Abu Dawood, Ibn Maajah)
This is why seeking forgiveness was legislated at the end of actions. Allah the Exalted said:
{{Those who seek forgiveness before dawn (at late night).}} (Quran, 3:17)
Some of them said: "Give life to your nights by performing Prayer, and when the time of late night comes, concern yourself with seeking forgiveness."
It is related in the Saheeh that the Prophet Muhammad (sallallahu `alaihi wa sallam), when he finished his Prayer, he would seek forgiveness three times and say:
{{O' my 'ilãh You are 'As-Salãm [One free from flaws], and from You comes Salãm [peace, or safety], blessed are Thee O' haver of glory and kindness.}} (Muslim)
Allah says:
{{And seek forgiveness of Allah. Indeed, Allah is Forgiving and Merciful.}} (Quran, 73:20)
(Even) After the Prophet conveyed the Message, fought in the path of Allah with true jihad, and performed what Allah ordered more than anyone else, Allah commanded his Prophet (to perform Istighfaar), as He the Exalted said:
{{When the victory of Allah has come and the conquest, and you see the people entering into the religion of Allah in multitudes, then exalt [Him] with praise of your Lord and ask forgiveness of Him. Indeed, He is ever Accepting of repentance.}} (Quran, 110:1-3)
This is why the religion (Deen) is established with Tawheed and Istighfaar, as Allah the Exalted said:
{{Alif Lam Ra. [This is] a Book whose verses are perfected and then presented in detail from [one who is] Wise and Acquainted. [Through a messenger, saying], "Do not worship except Allah. Indeed, I am to you from Him a warner and a bringer of good tidings," and [saying], "Seek forgiveness of your Lord and repent to Him, [and] He will let you enjoy a good provision.}} (Quran, 11:1-3)
And Allah says:
{{So take a straight course to Him and seek His forgiveness.}} (Quran, 41:6)
And He says:
{{So know [O Muhammad], that there is no deity except Allah and ask forgiveness for your sin and for the believing men and believing women.}} (Quran, 47:19)
This is why it was it came in a narration: {{The Shaytan said: People are destroyed with sins, and they destroy me with 'Laa ilaha ill Allah' and seeking forgiveness.}} (Reported by Ibn Abi Asim and Abu Ya`la, but its chain is a fabrication).
Yonus, `alayhis salam, said:
{{There is no deity except You; exalted are You. Indeed, I have been of the wrongdoers.}} (Quran, 21:87)
The Prophet (sallallahu `alaihi wa sallam), when he would ride his mount, he would praise Allah, then say Allahu Akbar three times, then say:
{{I testify that there is no 'ilah except You, Glorified are You, I have transgressed upon myself, so forgive me}} (Abu Dawood and at-Tirmidhi, who said it is Hasan Sahih)
Expiation of a gathering with which the gathering is completed is (the supplication):
{{Glorified are You O' my 'ilãh and I am in Your praise, I testify that there is no 'ilah except You, I ask Your forgiveness and repent unto You.}} (Abu Dawood and At-Tirmidhi, who said it is Hasan Sahih)
Allah knows best, and may His blessings and peace be upon [the Prophet] Muhammad.