the Sahīh, on the authority of Abū Hurayrah, that the Prophet, may Allah bless him and grant him peace, said:
“When the caller gives the call to prayer, Satan retreats, passing wind so that he cannot hear the call. When the call is finished, he returns. When the call to commence the prayer is given, he retreats; when it is finished, he returns and distracts a person, saying: ‘Remember such-and-such! Remember such-and-such!’—things he had not been thinking about—until he leads the man astray, leaving him unsure how much he has prayed. If any of you experiences this, let him perform two prostrations before giving the closing salutation.”
His statement was general, yet he did not instruct anyone to repeat the prayer.
The second opinion is that he must repeat it. This is the view of a group of scholars, both jurists and Sufis, among the followers of Ahmad and others, such as Abū Abd Allāh ibn Hāmid and others. They base this on his statement quoted earlier: “Only a tenth of it is recorded for him.”
The correct assessment is that he is rewarded only in proportion to his attentiveness. Nevertheless, he is spared the punishment deserved by one who abandons prayer. This is what they mean when they say, “His obligation is discharged by it”: he is not punished for failing to perform the prayer, but his reward is proportionate to his attentiveness. As Ibn Abbās said: “You have of your prayer only what you were conscious of.” This is why the regular Sunnah prayers were prescribed: to make up for deficiencies in the obligatory prayers. And Allah knows best.