The following excerpt is taken from islamqa in response to the question: What is the meaning of belief in al-Qadar (the divine will and decree)? (link):
Praise be to Allaah.
Qadar means that Allaah has decreed everything that happens in the universe according to His prior knowledge and the dictates of His wisdom.
Belief in al-Qadar includes four things:
1 – The belief that Allaah knows all things, in general and in detail, from eternity to eternity, whether that has to do with His actions or the actions of His slaves.
2 – The belief that Allaah has written that in al-Lawh al-Mahfooz (the Book of Decrees).
Concerning these two matters Allaah says (interpretation of the meaning):
“Know you not that Allaah knows all that is in the heaven and on the earth? Verily, it is (all) in the Book (Al‑Lawh Al‑Mahfooz). Verily, that is easy for Allaah”
In Saheeh Muslim (2653) it is narrated that ‘Abd-Allaah ibn ‘Amr ibn al-‘Aas (may Allaah be pleased with him) said: I heard the Messenger of Allaah (peace and blessings of Allaah be upon him) say: “Allaah wrote down the decrees of creation fifty thousand years before He created the heavens and the earth.”
And the Prophet (peace and blessings of Allaah be upon him) said: “The first thing that Allaah created was the Pen, and He said to it, ‘Write!’ It said, ‘O Lord, what should I write?’ He said: ‘Write down the decrees of all things until the Hour begins.” Narrated by Abu Dawood, 4700; classed as saheeh by al-Albaani in Saheeh Abi Dawood.
3 – The belief that whatever happens only happens by the will of Allaah – whether that has to do with His actions or the actions of created beings.
Allaah says concerning His actions (interpretation of the meaning):
“And your Lord creates whatsoever He wills and chooses”
“and Allaah does what He wills”
“He it is Who shapes you in the wombs as He wills”
[Aal ‘Imraan 3:6]
And He says concerning the actions of created beings (interpretation of the meaning):
“Had Allaah willed, indeed He would have given them power over you, and they would have fought you”
“If your Lord had so willed, they would not have done it”
All events, actions and happenings occur only by the will of Allaah. Whatever Allaah wills happens, and whatever He does not will does not happen.
4 – The belief that all things that happen are created by Allaah in their essence, their attributes and their movements.
Allaah says (interpretation of the meaning):
“Allaah is the Creator of all things, and He is the Wakeel (Trustee, Disposer of affairs, Guardian) over all things”
“He has created everything, and has measured it exactly according to its due measurements”
And Allaah tells us that the Prophet of Allaah Ibraaheem (peace and blessings of Allaah be upon him) said to his people:
“While Allaah has created you and what you make”
[al-Saaffaat 38:96 – interpretation of the meaning]
If a person believes in all these things then he believes correctly in the divine will and decree (al-qadar).
Belief in al-qadar as we have described it above does not contradict the idea that a person has free will with regard to actions in which he has free choice. He can choose whether to or not to do things that he is able to do of acts of worship or sinful actions. Sharee’ah and real life both indicate that people have this will.
With regard to sharee’ah, Allaah says concerning man’s will (interpretation of the meaning):
“That is (without doubt) the True Day. So, whosoever wills, let him seek a place with (or a way to) His Lord (by obeying Him in this worldly life)!”
“so go to your tilth, when or how you will”
And He says concerning man’s ability (interpretation of the meaning):
“So keep your duty to Allaah and fear Him as much as you can”
“Allaah burdens not a person beyond his scope. He gets reward for that (good) which he has earned, and he is punished for that (evil) which he has earned”
These verses confirm that man has a will and the ability to do what he wants and not to do what he does not want.
With regard to real life, everyone knows that he has a will and the ability to do what he wants and not to do what he does not want. And he can distinguish between the things that happen when he wants them to, such as walking, and those that happen without him wanting them to, such as shivering. But the will and ability of man are subject to the will and decree of Allaah, because Allaah says (interpretation of the meaning):
“To whomsoever among you who wills to walk straight.
And you cannot will unless (it be) that Allaah wills the Lord of the ‘Aalameen (mankind, jinn and all that exists)”
But the entire universe is the dominion of Allaah, and nothing can happen in His dominion without His knowledge and will.
And Allaah knows best.
See Risaalat Sharh Usool al-Eemaan by Shaykh Ibn ‘Uthaymeen.