In answering this question, we would like to quote Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) who commented on hadith of Abdullah bn Mas’ud that when a person is in the womb of his mother, an angel would be sent to write four things about him…, he said:

This hadith and similar reports point to two concepts:

1 – The prior decree, which means that Allah already knows who are the people of Paradise and who are the people of Hell before they do any deeds. This is true and must be believed in. Indeed the imams, such as Malik, al-Shafa`i and Ahmad, have stated that the one who denies this is a kafir. Rather we must believe that Allah knows everything that is going to happen before it happens, and we must believe in what He has told us concerning the fact that He has decreed what will happen and has told us of it before it happens.

2 – That Allah knows all things the way they are, and He has made for every thing ways that may lead to it. So He knows that these things could result from these means, as He knows that this man may have a child by means of having intercourse with a woman that makes her pregnant. If this man says: Allah knows that I am going to have a child so there is no need for me to have intercourse, then he is a fool, because Allah knows that it will come about by means of the intercourse He has decreed. Similarly, a man knows that crops will grow as the result of watering the seeds that he has planted, but if he says: Allah knows that it will happen so there is no need to plant seeds, then he is ignorant and misguided because Allah knows what will come about by those means.

Thus, if He knows that this one will be blessed in the Hereafter and that one will be doomed, we say: it is because that one does the deeds of the doomed, so Allah knows that he will be doomed because of his deeds. If it is said that he is doomed even if he does not do anything, this is false, because Allah does not admit anyone to Hell except for his sin, as Allah says: “That I will fill Hell with you [Iblis (Satan)] and those of them (mankind) that follow you, together” [Sad 38:85]. So He swore to fill it with Iblis and his followers, and those who follow Iblis have disobeyed Allah, may He be exalted. Allah does not punish anyone for what He knows he will do until he does it.

Similarly, Allah has decreed Paradise for the people who believe in Him and obey Him, so the one who is decreed to be one of them is guided by Allah to believe and obey. The one who says, I will enter Paradise whether I am a believer or a disbeliever, if He knows that I am one of its people, is fabricating a lie against Allah. Allah knows that he will be admitted to it by faith, so if he does not have faith he will not be the one who Allah knew would enter Paradise, rather he will be not a believer but a kafir, and Allah knows that he will be one of the people of Hell, not one of the people of Paradise.

Hence, Allah commanded people to pray, seek forgiveness from Allah and other means. The one who says, I will not pray or ask, and I will rely on the divine decree, is also mistaken, because Allah has made praying and asking means of attaining His forgiveness, mercy, guidance, support and provision. If He has decreed some good for a person to be attained by means of du`aa’ that will not be attained it without du`aa’. What Allah has decreed and knows about people’s situations and how their lives will end, it is only decreed through the means that lead to that specific outcome. Nothing in this world or in the Hereafter happens except through means, and Allah is the Creator of the means and the ends.

With regard to this matter, two types of people go astray. There are those who believe in the divine decree and think that it is sufficient to attain one’s aims, so they turn away from the prescribed means and righteous deeds. They will end up disbelieving in the Books of Allah, His Messengers and His religion.

(The other group) ask for reward from Allah as a hired man asks for his wages from his employer, relying on their own power, strength and deeds. These people are ignorant and misguided, because Allah has not enjoined His commands upon people out of need, and He has not imposed His prohibitions out of stinginess, rather He has enjoined what is in their best interests and He has forbidden that which is bad for them. As He says: “You will never be in a position where you are able to harm Me and you will never be in a position to benefit Me.”

The one who turns away from the commands and prohibitions, promises and warnings, and focuses only on the divine decree has gone astray, and the one who strives to follow the commands and prohibitions and ignores the divine decree has gone astray. Rather the believer has to pray as Allah says: “You (Alone) we worship, and You (Alone) we ask for help (for each and everything)” [al-Fatihah 1:5], so we worship Him by following the command, and we seek His help on the basis our belief in the divine decree.