The Messenger of Allah ﷺ used to teach them this supplication just as he taught them a surah from the Quran. He would say, "Say, O Allah, we seek refuge in You from the punishment of Hell, and I seek refuge in You from the punishment of the grave, and I seek refuge in You from the trial of the Masih the Dajjal, and I seek refuge in You from the trials of life and death."
إن رسول الله ﷺ كان يعلمهم هذا الدعاء كما يعلمهم السورة من القرآن، يقول: قولوا اللهم إنا نعوذ بك من عذاب جهنم، وأعوذ بك من عذاب القبر، وأعوذ بك من فتنة المسيح الدجال، وأعوذ بك من فتنة المحيا والممات.
Muslim narrated it in the Book of Mosques (590), from Qutayba bin Saeed, from Malik bin Anas, from Abu Zubayr, from Tawus, from Ibn Abbas, and he mentioned it.Muslim said, "It has reached me that Tawus said to his son, 'Did you supplicate with it in your prayer?' He said, 'No.' He said, 'Repeat your prayer.'" This is because Tawus narrated it from three or four narrators, or however many he said.Nawawi said, "The apparent meaning of Tawus's words is that he took the command regarding it as obligatory, and so he required the prayer to be repeated because it had been omitted. But the majority of scholars hold that it is recommended, not obligatory, and perhaps Tawus intended to discipline his son and to emphasize how important this supplication was to him, not that he believed it obligatory." End of quote.Among those who held that it is not obligatory is Imam Bukhari, for he titled a chapter, "Chapter on choosing whichever supplication one wishes after the tashahhud, though it is not obligatory," and he used as evidence for this the hadith of Abdullah bin Masud, "Then let him choose whichever supplication pleases him and supplicate with it," for this turns the command form in the words, "let him seek refuge in Allah from four things," from being obligatory to being recommended, and this is the view of the majority of scholars.Likewise sending blessings upon the Prophet ﷺ after the tashahhud, except that Shafii held it obligatory after the tashahhud.As for supplications, the majority permitted the one praying to choose whatever supplications he wished in prayer concerning matters of this world and the hereafter, based on what was mentioned in the tashahhud of Ibn Masud, "Then let him choose whatever request he wishes," and in another narration, "Then afterward let him choose whatever request he wishes."Abu Hanifa and those who agreed with him restricted this, saying that one should not supplicate in prayer except with what is found in the Quran or established in hadith. But the apparent meaning of the hadith of Ibn Masud supports what the majority held. Abu Bakr bin Abu Shayba narrated (1/296) through the route of Umayr bin Saeed, who said, "Abdullah (bin Masud) used to teach us the tashahhud in prayer, then he would say, 'When one of you finishes the tashahhud in prayer, let him say, "O Allah, I ask You for all good, what I know of it and what I do not know, and I seek refuge in You from all evil, what I know of it and what I do not know. O Allah, I ask You for the good that Your righteous servants have asked You for, and I seek refuge in You from the evil that Your righteous servants have sought refuge from. Our Lord, grant us good in this world and good in the hereafter, and protect us from the punishment of the Fire. Our Lord, we have indeed believed, so forgive us our sins, and remove from us our misdeeds, and cause us to die among the righteous. Grant us what You promised us through Your messengers, and do not disgrace us on the Day of Resurrection, for You do not break Your promise."'"This supplication is not something that appears in its entirety in either the Quran or the sunnah, except that Abdullah bin Masud used to teach it to his companions.