Praise be to Allah.
Having the correct intention and calling it to mind when starting to do the deed, is one of the most important things that a person should strive to attain, because the acceptance or rejection of deeds is connected to that, and the kind of intention he has in his mind will have an impact on his spiritual well-being, for spiritual well-being cannot be attained unless his deeds and efforts are solely for the sake of Allah.
The Prophet (blessings and peace of Allah be upon him) said: “Deeds are but by intentions, and each person will have but that which he intended.” Agreed upon.
An-Nawawi (may Allah have mercy on him) said:
The Muslims are agreed upon the great importance of this hadith, the great benefits it teaches and the soundness of this report.
Then he said:
The majority of scholars, including linguists, scholars of usool and others, said that the wording of the hadith means that deeds are strongly connected to intention, as it affirms what is mentioned that negates everything else. So this hadith may be understood as meaning that righteous deeds are counted as such if there is a sound intention, and they are not counted as such if there is no sound intention. This indicates that purification (tahaarah) – which includes wudoo’, ghusl and tayammum – is not valid unless it is preceded by the intention. The same applies to prayer, zakaah, fasting, Hajj, i‘tikaaf and all other acts of worship.
End quote from Sharh Muslim by an-Nawawi (13/47).
Ibn Rajab (may Allah have mercy on him) said:
The words that follow that, “and each person will have but that which he intended” form a statement that what a person gets from his deeds is dependent upon what he intended thereby. If he intended good, he will attain good, and if he intended evil, he will attain evil. This is not merely a repetition of the first sentence, because the first sentence indicates that the soundness or otherwise of the deed is dependent upon the intention behind the deed, whilst the second sentence indicates that the reward of the doer for his deed will be commensurate with his sound intention, and his punishment for it will be commensurate with his bad intention. His intention may be permissible, in which case the deed is also permissible, but he may attain neither reward nor punishment. Whether the deed is valid, invalid or permissible is determined on the basis of the intention that motivated him to do it and led to the deed being done; and the reward or punishment of the doer, and whether the deed is sound or not, is dependent upon the intention, because of which the deed will be either valid, invalid or permissible.
End quote from Jaami‘ al-‘Uloom wa’l-Hikam (1/65). See also I‘laam al-Muwaqqi‘een (3/91).
The intention on the basis of which deeds are judged to be either valid or invalid, and concerning which the fuqaha’ speak, is the intention by which one differentiates between the good deed one is doing and other good deeds. As for the intention which is connected to whether the deed will be accepted or rejected, it is the intention which shows whether the deed is done for the sake of Allah or not, and this is what may be described as sincerity.
Ibn Rajab (may Allah have mercy on him) said:
It should be understood that the word niyyah (intention) in linguistic terms refers to a kind of purpose or aim, even though there may be some differences between these terms; this is not the place to discuss that.
The word niyyah, in the discourse of the scholars, has two meanings:
The first is that intention which distinguishes one act of worship from another, such as distinguishing Zuhr prayer from ‘Asr prayer, or distinguishing the fast of Ramadan from other fasts, or distinguishing acts of worship from habits, such as distinguishing ghusl in the case of janaabah from “ghusl” (bathing) in order to cool down or clean oneself, and the like. This niyyah is what is often referred to by the fuqaha’ in their books.
The second meaning is the intention which determines who the deed is intended for, and whether it is for the sake of Allah alone, with no partner or associate, or for someone else, or for Allah and someone else. This niyyah is mentioned in books that speak of spiritual matters, such as sincerity and the like. It is the intention that is often mentioned in the words of the earlier salaf.
End quote from Jaami‘ al-‘Uloom wa’l-Hikam (1/65).
To sum up:
The niyyah on which the validity or soundness of the deed depends is the intention that makes the particular act that the person wants to do distinct from another, so it distinguishes ghusl in the case of janaabah from bathing in order to clean oneself or cool down, and so on.
This is what is required in order for the deed to be valid.
With regard to the intention of drawing closer to Allah, this is a matter concerning which people vary a great deal, and Allah will appreciate the doer and his deed commensurate with the degree to which he achieves this intention and how sincerely it is done for the sake of Allah.
In that regard, it is not essential for the doer to call to mind the intention of drawing closer to Allah with this specific wording. Rather if he intends to do an act of worship, or to worship Allah and obey Him, or to adhere to His command, and other sound, shar‘i purposes, that is sufficient.
See: al-Mawsoo‘ah al-Fiqhiyyah (33/92 ff); Maqaasid al-Mukallifeen by al-Ashqar (50-56).
Perhaps this is why some of the fuqaha’ were of the view that it is not essential to have the specific intention of drawing closer to Allah when doing righteous deeds; rather it is sufficient to intend to do the specific deed or specific act of worship, whilst distinguishing it from others.
See: at-Talkhees fi Usool al-Fiqh by al-Juwayni (1/486); al-Mustasfa min ‘Ilm al-Usool by al-Ghazaali (1/62).
This intention, which is required in order for the deed to be acceptable, is usually already in the person’s mind when he does the deed. Otherwise, what would prompt the one who wants to enter Islam to do ghusl? And what would prompt the menstruating woman, when her period ends, to do ghusl, especially when it is very cold?
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
A person may have in his heart intentions, thoughts and emotions, without realizing that they are there. Having something in the heart is one thing, and being aware of it is something else. Hence you may find someone who tries hard to have a certain thought or feeling or intention in his heart, when it is already there, so you see him putting a great deal of effort into that because of his ignorance. This is like the one who experiences waswaas (whispers from the Shaytaan; persistent thoughts doubting the correctness of his prayer). Anyone who does an action voluntarily and knows what he is doing must already have formed an intention (connected to his action). The idea that he would do that deed without any intention or the will to do it is something that is not possible. The one who knows that he is getting up to pray wants to pray; it cannot be imagined that he would pray unless he wants to pray, so for such a person to strive to attain the intention (niyyah) is a sign that he is unaware of the nature of the intention that is already in his heart.
Similarly, if someone knows that tomorrow is a day of Ramadan, and he is a Muslim who believes that it is obligatory to fast and he wants to fast, then that is the intention of fasting, and when he has his supper, he will have the supper of one who wants to fast. Therefore he will have a different supper on the night before Eid compared to his supper on the nights of Ramadan, because on the night of Eid, he knows that he will not be fasting the next day; he does not want to fast and he does not intend to fast, and he will not eat the supper of one who intends to fast.
This is like one who eats, drinks, walks, rides, and gets dressed, and he knows what he is doing when he does all of these deeds; he must inevitably want to do them, and this is his intention. If he were to say out loud: I want to put my hand in this vessel in order to take a morsel of food to eat, then he would appear very foolish to other people. The same applies to the one who utters such phrases when intending to pray, purify himself or fast.
End quote from Minhaaj as-Sunnah an-Nabawiyyah (5/398-399).
Ibn al-Qayyim (may Allah have mercy on him) said:
The intention (niyyah) means aiming to do something; everyone who has decided to do something is intending to do it, and it is not possible that this could be separate from the intention, because that is the essence thereof. It cannot be imagined that the intention is not there when the decision to do the deed is there. The one who starts to do wudoo’ has intended to do wudoo’, and the one who stands to pray has intended to pray; hardly any person of sound mind would do any act of worship or any other deed without having already formed the intention of doing it. Therefore the intention is something that is strongly connected to whatever deeds a person decides to do, and there is no need to try hard to achieve it. If he wanted to do any action voluntarily without having any intention, he would fail to do that. If Allah, may He be glorified and exalted, made it obligatory to pray and do wudoo’ without the intention, then He would be obliging people to do something that they are unable to do and that would be beyond them.
End quote from Ighaathat al-Lahfaan (1/137).
And Allah knows best.