Conditions for deeds to be acceptable to Allaah

When a Muslim does an action, what conditions make it acceptable and therefore rewarded by Allah.  Is it simply that you intended to follow the Qur'an and Sunnah, and therefore you will be rewarded even though you may have been wrong in your action.  Or is it that you must have the intention, but you also need to follow the correct Sunnah as well.

Praise be to Allaah.
For acts of worship to be acceptable to Allaah and for a person to be rewarded for them, there are two conditions which must be met:

The first condition: it should be devoted to Allaah Alone. Allaah says (interpretation of the meaning):

“And they were commanded not, but that they should worship Allaah, and worship none but Him Alone (abstaining from ascribing partners to Him)”

[al-Bayyinah 98:5]

The meaning of worshipping Allaah alone is that the person should intend in all his words and deeds, both inward and outward, to seek the Face of Allaah (i.e., His pleasure). Allaah says (interpretation of the meaning):

“And who has (in mind) no favour from anyone to be paid back,

Except to seek the Countenance of his Lord, the Most High”

[al-Layl 92:19]

“(Saying): “We feed you seeking Allaah’s Countenance only. We wish for no reward, nor thanks from you”

[al-Insaan 76:9]

“Whosoever desires (by his deeds) the reward of the Hereafter, We give him increase in his reward, and whosoever desires the reward of this world (by his deeds), We give him thereof (what is decreed for him), and he has no portion in the Hereafter”

[al-Shoora 42:20]

“Whosoever desires the life of the world and its glitter, to them We shall pay in full (the wages of) their deeds therein, and they will have no diminution therein.

They are those for whom there is nothing in the Hereafter but Fire, and vain are the deeds they did therein. And of no effect is that which they used to do”

[Hood 11:15-16]

It was narrated that ‘Umar ibn al-Khattaab (may Allaah be pleased with him) said: “I heard the Messenger of Allaah (peace and blessings of Allaah be upon him) say:

‘The reward of deeds depends upon the intentions and every person will get the reward according to what he has intended. So whoever emigrated for worldly benefits or for a woman to marry, his emigration was for what he emigrated for.’”

(Narrated by al-Bukhaari, Bad’ al-Wahy, 1).

It was narrated by Muslim from Abu Hurayrah that the Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Allaah, may He be blessed and exalted, says: ‘I am so self-sufficient that I am in no need of having an associate. Thus he who does an action for someone else’s sake as well as Mine will have that action renounced by Me to him whom he associated with Me.’” (Narrated by Muslim, al-Zuhd wa’l-Raqaa’iq, 5300)

The second condition is that the action should be in accordance with the only way which Allaah has prescribed for worship, which is by following the Prophet (peace and blessings of Allaah be upon him)  in the laws that he has brought. It was narrated that the Prophet (peace and blessings of Allaah be upon him)  said: “Whoever does any action that is not in accordance with this matter of ours (i.e., Islam), will have it rejected.” (Narrated by Muslim, al-Aqdiyyah, 3243).

Ibn Rajab (may Allaah have mercy on him) said: “This hadeeth forms one of the most  important principles of Islam. It is like a scale for weighing up deeds according to their outward appearance, just as the hadeeth ‘The reward of deeds depends upon the intentions’ is the means of weighing up the inner nature of deeds. Just as every action which is not intended for the sake of Allaah brings no reward to the one who does it, so too every deed which is not in accordance with the command of Allaah and His Messenger will also be rejected and thrown back at the one who does it. Everyone who innovates in Islam something for which Allaah and His Messenger have not granted permission, that thing is nothing to do with Islam.

(Jaami’ al-‘Uloom wa’l-Hukam, part 1, p. 176)

The Prophet (peace and blessings of Allaah be upon him) enjoined following his Sunnah and teachings, and made them binding. He (peace and blessings of Allaah be upon him) said: “You have to follow my Sunnah (way) and the way of my rightly-guided successors (al-khulafa’ al-raashidoon); bite onto it with your eyeteeth (i.e., cling firmly to it).” And he warned against bid’ah (innovation), as he said: “Beware of newly-invented matters, for every newly-invented matter is a going astray.” (narrated by al-Tirmidhi, al-‘Ilm, 2600; classed as saheeh by al-Albaani in Saheeh Sunan al-Tirmidhi, no. 2157)

Ibn al-Qayyim said: “Allaah has made devotion of worship to Him alone and following the Sunnah the means of deeds being accepted; if these conditions are not met, then deeds are unaccaptable.”

(al-Rooh, 1/135)

Allaah says (interpretation of the meaning):

“Who has created death and life that He may test you which of you is best in deed”

[al-Mulk 67:2]

al-Fudayl said: “’best in deed’ means, most devoted to Allaah alone and most in accordance with the Sunnah.

And Allaah is the Source of strength.