by the sunnah.’ End quote.
Allah has threatened those who show off with an announcement of woe; He, the Exalted, says: “So woe to those who pray, yet are heedless of their prayer, those who make a display and withhold small acts of kindness.” ⦗1⦘
He has also informed us that ostentation is one of the traits of the hypocrites; He said: “Indeed, the hypocrites seek to deceive Allah, but He is deceiving them; when they rise for prayer, they rise lazily, merely showing off to the people.” ⦗2⦘
Abu Hurayrah narrated—in a hadith traced back to the Prophet—that Allah the Exalted said: “I am the One most free of any need for partners. Whoever performs a deed in which he associates someone else with Me, I abandon him and his association.” Recorded by Muslim. That is: whoever intends through his deed someone other than Me from among the creation, I abandon him and his shirk. In another wording reported by Ibn Majah: “I am innocent of him; the deed is for the one he associated.”
Ibn Rajab, may Allah have mercy on him, said: “Know that working for other than Allah falls into several categories. At times it is pure ostentation, like the condition of the hypocrites, as Allah says: ‘When they stand for prayer, they stand lazily, showing off to the people.’ ⦗3⦘ This unadulterated ostentation is hardly found in a believer with respect to the obligatory prayer or fasting, though it may occur in obligatory charity, the obligatory pilgrimage, or other outward acts whose benefit extends to others, for sincerity in such deeds is rare. Every Muslim agrees that this deed is null and that its doer deserves Allah’s wrath and punishment.
“At other times the deed is for Allah but is accompanied by ostentation. If the ostentation is present from the very start, the sound textual proofs show that the deed is invalid. If, however, the deed was initially for Allah and the intention to show off arose later, then if it is only a passing thought which he dismisses, it does not harm him—there is no disagreement on this. If he goes along with it, the early scholars differed: does it nullify his deed or not—will he be rewarded according to his original intention? This difference was reported by Imam Ahmad and Ibn Jarir, and they both preferred the view that his deed is not thereby nullified,