What are the conditions which must be met for a deed to be righteous?

Praise
be to Allah

Shaykh al-Shanqeeti said:

What is meant in the aayah

“…who do righteous deeds…”

[al-Kahf 18:2 – interpretation of the
meaning]

 is explained in other aayahs which indicate
that a deed cannot be righteous unless it meets three conditions:

1 – It must be
done in accordance with that which was brought by the Prophet SAWS (peace
and blessings of Allaah be upon him). Every action that goes against that
which was brought by the Prophet (peace and blessings of Allaah be upon him)
is not righteous, rather it is false. Allaah says (interpretation of the
meaning):

“And whatsoever the Messenger (Muhammad)
gives you, take it”

[al-Hashr 59:7]

“He who obeys the Messenger (Muhammad),
has indeed obeyed Allaah”

[al-Nisa’ 4:80]

“Or have they partners with Allaah (false
gods) who have instituted for them a religion which Allaah has not
ordained?”

[al-Shoora 42:21]

and there are many similar aayahs.

2 – The one who does it must be sincere in
his intention towards Allaah. Allaah says (interpretation of the meanings):

“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 :5]

“Say (O Muhammad): ‘Verily, I am
commanded to worship Allaah (Alone) by obeying Him and doing religious deeds
sincerely for His sake only.

And I am commanded (this) in order that I
may be the first of those who submit themselves to Allaah (in Islam) as
Muslims.’

Say (O Muhammad): ‘Verily, if I disobey
my Lord, I am afraid of the torment of a great Day.’

Say (O Muhammad): ‘Allaah Alone I worship
by doing religious deeds sincerely for His sake only (and not to show off,
and not to set up rivals with Him in worship).’

So worship what you like besides Him’”

[al-Zumar 39:11-15]

and there are many similar aayahs.

3 – It must be done on the basis of faith
and sound belief, because the action is the roof and the belief (‘aqeedah)
is the foundation. Allaah says (interpretation of the meaning):

“Whoever works righteousness — whether
male or female — while he (or she) is a true believer…”

[al-Nahl 16:97]

So faith is described as the prerequisite
for that.

The concept of this prerequisite is
explained in many places, such as when Allaah describes the actions of
non-believers:

“And We shall turn to whatever deeds they
(disbelievers, polytheists, sinners) did, and We shall make such deeds as
scattered floating particles of dust”

[al-Furqaan 25:23]

“their [disbelievers’] deeds are like a
mirage in a desert”

[al-Noor 24:39]

“their [disbelievers’]works are as ashes,
on which the wind blows furiously on a stormy day”

[Ibraaheem 14:18]

and there are many similar aayahs as
explained above.