Hanifa said: It does not become void by that, because it is an act of worship into which he has rightfully entered, so it does not become corrupted by the intention to exit from it, just like Hajj. Our [position] is that he has severed the validity of the intention before completing his prayer, so it becomes corrupt, just as if he had performed the Taslim intending to exit from it. Also, because intention is a condition for the entire prayer, and he has severed it by what occurred, so it became corrupt due to the disappearance of its condition. It differs from Hajj, for one does not exit from it by [committing] its forbidden acts or its corrupting acts, unlike prayer. As for if he oscillates regarding cutting it off, Ibn Hamid said: It does not become void because he entered into it with a certain intention, so it is not removed by doubt and oscillation, like other acts of worship. The Qadi said: It is possible that it becomes void. This is the school of Al-Shafi'i; because maintaining the intention is a condition, and with oscillation, he is not maintaining it, so it is similar to if he intended to cut it off.
Section: The obligation is to maintain the validity of the intention, not its essence, in the sense that he does not intend to cut it off. If he becomes heedless of it and it slips from his mind during the prayer, this does not affect its validity, because being cautious against this is not possible, and because the essence of the intention is not considered during the act of worship, as evidenced by fasting and other acts. It has been narrated from the Prophet (may Allah bless him and grant him peace) that he said: "When the prayer is called, Satan turns back, passing wind (7), and when the prayer is established (taswib), he comes forward until he whispers between a man and his soul, saying: 'Remember such and such, remember such and such,' until one of you remains not knowing how much he has prayed." This is agreed upon (8). Malik also narrated it in the "Muwatta" (9). It is narrated from Umar, may Allah be pleased with him, that he prayed a prayer and did not recite in it, so it was said to him: "You did not recite." He said: "I was equipping an army for the Muslims until I reached Wadi al-Qura (10) with it."
(7) Al-hisas: passing wind. (8) Reported by Al-Bukhari in: The Chapter on the Virtue of the Adhan, from the Book of Adhan; and in: The Chapter of a Man Thinking about Something during Prayer, from the Book of Action in Prayer; and in: The Chapter of If One Does Not Know How Much He Has Prayed, Three or Four, He Prostrates Twice While Sitting, and the Chapter of Forgetfulness in Obligatory and Voluntary [Prayers], from the Book of Forgetfulness; and in: The Chapter on the Description of Iblis and His Hosts, from the Book of the Beginning of Creation. Sahih Al-Bukhari 1/158, 2/84, 85, 87, 4/151. And Muslim in: The Chapter on the Virtue of the Adhan and the Flight of Satan When He Hears It, from the Book of Prayer; and in: The Chapter of Forgetfulness in Prayer and Prostration for It, from the Book of Mosques. Sahih Muslim 1/291, 292, 398, 399. Also reported by Abu Dawud in: The Chapter on Raising the Voice in the Adhan, from the Book of Prayer. Sunan Abi Dawud 1/123. Al-Nasa'i in: The Chapter on the Virtue of the Adhan, from the Book of Adhan. Al-Mujtaba 2/19. Al-Darimi in: The Chapter of Satan When He Hears the Call He Flees, and the Chapter of a Man Who Does Not Know Whether He Prayed Three or Four, from the Book of Prayer. Sunan Al-Darimi 1/273, 350, 351. And Imam Ahmad in: Al-Musnad 2/313, 460, 483, 503, 504, 522. (9) In: The Chapter on What Has Come Regarding the Call to Prayer, from the Book of the Call. Al-Muwatta 1/69, 70.