Mandatory Conditions for accepting acts of worship
There are two main conditions for accepting one's worship:
· Following in the footsteps of Allah's Messenger (peace and blessings be upon him).
Sheikh al-Islam, ibn Taymiya said: "The religion of Islam is based on two main principles: to worship none but Allah through what He has legislated [Shari'ah] and not through innovation [Bid'a] as per His words, "So whoever would hope for the meeting with his Lord - let him do righteous work and not associate in the worship of his Lord anyone" [Al-Kahf:110]. This incorporates admitting the two testifications of faith [Ash-Shahada]—i.e. to testify that there is no god but Allah and that Muhammad is the Messenger of Allah. The first part of the Shahada confirms the Oneness of Allah and the second part confirms that Muhammad (pbuh) is the Messenger who conveyed Allah's Message; thus, we have to believe in what he said and obey his commands."
Therefore, whoever wants to worship Allah, he must abide by these two conditions along with being convinced that He seeks Allah's guidance through what He Almighty has Legislated.
Al-Fudail ibn 'Iyad commented on the words of Allah in Surah al-Mulk , the second verse "to test you [as to] which of you is best in deed": "The best in deeds here means the most sincere and right deed." People asked him: "What does the most sincere and right deed mean?" He replied: "If one's deed is done sincerely but in a wrong way, it would not be accepted; if a deed is done in a right way but not out of sincerity, it would not be accepted. A deed is only accepted when it is done out of sincerity and in a right way. A sincere deed that one does for Allah's sake and in a right way means that a person follows in the Sunnah [of the Prophet] in doing it."
Hence, if these two conditions or any of them are neglected, one's worship will be invalid.
- If a person performed prayers for other than Allah and contradicted the manner prescribed by the Messenger of Allah (pbuh) in offering it, his prayer will be rejected by Allah. This is because his act of worship [prayer] lack the two main conditions for accepting it [i.e. Ikhlas and following the Prophet].
- Likewise, if a person follows the teachings of the Prophet in offering his prayer but he prays for other than Allah, his worship will be invalid. This is because his worship lack sincerity. Allah Almighty says,
Indeed, Allah does not forgive association with Him, but He forgives what is less than that for whom He wills.[An-Nisa':48]
But if they had associated others with Allah , then worthless for them would be whatever they were doing.[Al-'An'am:88]
- If a person offers his prayer for Allah's sake [sincerity]; however, he deviated from the manner prescribed by the Prophet (pbuh) in offering it, his worship will be invalid because it lacks following in the footsteps of the Messenger (pbuh). The Prophet (pbuh) said in the hadith: "Whoever does a deed which contradicts our religion, it will be rejected." in another phrasing of the hadith, it was reported that the Prophet (pbuh) said: "Whoever brings innovation to our religion, it will be rejected."
In fact, these two conditions are inseparable. Meaning, sincerity necessitates following the Prophet (pbuh) while following the Prophet necessitates sincerity.
 See Al-'Ubudiyya p.170.
 See Al-'Ubudiyya p. 76.
Recorded by Muslim (1718) and Ahmed (vol.6, p.146).
 Recorded by Bukhari (vol.3, p.167) and Muslim (1718).