(1) بَاب كَيْفِيَّةِ خَلْقِ الْآدَمِيِّ فِي بَطْنِ أُمِّهِ وَكِتَابَةِ رِزْقِهِ وَأَجَلِهِ وَعَمَلِهِ وَشَقَاوَتِهِ وَسَعَادَتِهِ
Abu al-Aswad reported that 'Imran b Husain asked him:
What is your view, what the people do today in the world, and strive for, is it something decreed for them or preordained for them or will their fate in the Hereafter be deterrained by the fact that their Prophets brought them teaching which they did not act upon? I said: Of course, it is something which is predetermined for them and preordained for them. He (further) said: Then, would it not be an injustice (to punish them)? I felt greatly disturbed because of that, and said: Everything is created by Allah and lies in His Power. He would not be questioned as to what He does, but they would be questioned; thereupon he said to me: May Allah have mercy upon you, I did not mean to ask you but for testing your intelligence. Two men of the tribe of Muzaina came to Allah's Messenger (ﷺ) and said: Allah's Messenger, what is your opinion that the people do in the world and strive for, is something decreed for them; something preordained for them and will their fate in the Hereafter be determined by the fact that their Prophets brought them teachings which they did not act upon. and thus they became deserving of punishment? Thereupon, he said: Of course, it happens as it is decreed by Destiny and preordained for them, and this view is confirmed by this verse of the Book of Allah, the Exalted and Glorious:" Consider the soul and Him Who made it perfect, then breathed into it its sin and its piety" (xci. 8).
Reference: Sahih Muslim 2650
In-book reference: Book 46, Hadith 17
USC-MSA web (English) reference(deprecated numbering scheme): Book 33, Hadith 6406