Abu Hanifah: It is disliked; because the Prophet - peace and blessings of Allah be upon him - lived during the days of the conquests, and he sought rain and was given it, yet it was not reported that he prostrated. Had it been recommended, he would not have neglected it. As for us, there is what Ibn al-Mundhir narrated with his chain of transmission from Abu Bakrah, that the Prophet - peace and blessings of Allah be upon him - used to fall down prostrating when a matter of joy came to him. [And it was narrated by Abu Dawud (55), and its wording is: He said: He used to "if a matter of joy came to him" (56), or he was given good news, he would fall down prostrating as a sign of gratitude to Allah. Al-Tirmidhi said: This is a hasan gharib (good but singular) hadith] (57). Al-Siddiq (Abu Bakr) prostrated when [he was given the good news of the conquest] (58) of al-Yamamah, and 'Ali prostrated when he found Dhu al-Thudayyah (59). [Meaning: when he found him among the Khawarij; because the Prophet - peace and blessings of Allah be upon him - had informed about him and described him] (60). It was also narrated from a group of the Companions, so its appearance and proliferation were established. [Thus, what they said is refuted] (60), and neglecting it at times does not prove that it is not recommended, for a recommended act is performed at times and omitted at others. [If this is established, then the nature of the prostration of gratitude in its actions, rulings, and conditions is like the nature of the prostration of recitation, based on what we have mentioned] (61).
Section: He should not perform the prostration of gratitude while in prayer, because the cause for the prostration is not from the prayer. If he does so, his prayer is invalidated, [as if he performed another prayer within it] (62), unless he was forgetful or ignorant of the prohibition of doing so, [then it does not invalidate it, because it is not an excessive action, so it is like when he adds a prostration in prayer due to forgetfulness] (62). As for [when we say: It is a prostration of gratitude] (63), it is possible that [it does not invalidate it; because its cause is within the prayer, so it resembles the obligatory prostrations, and it is possible that it does invalidate it; because it is a prostration of gratitude] (64).
(55) In: The chapter on the prostration of gratitude, from the Book of Jihad. Sunan Abi Dawud 2/81. It was also recorded by al-Tirmidhi, in: The chapter on what was narrated regarding the prostration of gratitude, from the Book of Siyar. 'Aridat al-Ahwadhi 7/73. And Ibn Majah, in: The chapter on what was narrated regarding prayer and the prostration of gratitude, from the Book of Establishing Prayer. Sunan Ibn Majah 1/446. (56) In Sunan Abi Dawud: "If a matter of joy came to him". (57) Omitted from: The original. (58) In (M): "conquest". Recorded by 'Abd al-Razzaq, in: The chapter on a man prostrating out of gratitude, from the Book of the Virtues of the Quran. Al-Musannaf 3/358. And al-Bayhaqi, in: The chapter on the prostration of gratitude, from the Book of Prayer. Al-Sunan al-Kubra 2/371. (59) Dhu al-Thudayyah was described as having an upper arm but no forearm, and on the end of his upper arm was something like a woman's breast nipple. He was one of the Khawarij against 'Ali - may Allah be pleased with him. You can find his story in: Al-Isaba 2/409, 401, just as his hadith was recorded by Muslim, in: The chapter on inciting the killing of the Khawarij, from the Book of Zakat, Sahih Muslim 2/748, 749. And Abu Dawud, in: The chapter on fighting the Khawarij, from the Book of Sunnah. Sunan Abi Dawud 2/543. (60) Omitted from: The original. (61) In (M): "And what is required for the prostration of gratitude is what is required for the prostration of recitation. And Allah knows best." (62) Omitted from: (M).