Shaykh Muḥammed ibn Ṣāliḥ al-‘Uthaymīn:

He ﷺ said: “By The One whom none is worthy of worship except He, Indeed one of you may perform the deeds that the people destined for Paradise do until nothing is between him and paradise except a hand-span. Then, what is in the book of pre-decree comes to pass and so he performs the deeds that the people destined for hellfire do.” But the good news, O’ brothers, is that this Hadīth has a context. i.e. He performs the deeds that the people destined for Paradise do, according to what is apparent to people, and in reality he will be among the dwellers of Hellfire.

As for he who sincerely, from his heart, performs the deeds that the people destined for Paradise do, Allah ﷻ will not forsake him. Allah is more gracious than that. If you sincerely perform the deeds that the people destined for Paradise do – may Allah make us from them – Allah will certainly not forsake you, but [the issue is] what is apparent to the people.

The proof for this context is established in the authentic collection of al-Bukhāri: A man was with The Prophet ﷺ in a battle. He was brave and daring; he did not spare any one among the enemy except that he killed him. The people were amazed at his bravery and daringness. The Prophet ﷺ then said on that day: “Indeed he will be among the dwellers of the Hellfire”. – I ask Allah for refuge – This brave man who is eradicating the enemy will be among the dwellers of the Hellfire?! This was of major concern and worry for the Muslims, they were frightened: How can this man end-up among the dwellers of Hellfire?!

A man then said: By Allah, I’m going to shadow him! Meaning: I’m going to follow him so as to see how he ends up. So he went with the man, and during the battle the brave man was stuck by an arrow. He then lost hope, so he took his own sword, pointed it at his own chest and thrust himself onto it such that it came out of his back. – I ask Allah for refuge – He killed himself due to his despair.

The man then came to The Prophet ﷺ and said: O’ Messenger of Allah, I bear witness that none is worthy of worship except Allah, and you are the messenger of Allah. He ﷺ said: “Because of what? He replied: “The man who you declared to be among the dwellers of Hellfire done such-and-such.” The Prophet ﷺ then said: “Indeed a man may perform the deeds that the people destined for Paradise do, according to what is apparent to the people – all praise due to Allah for this context – and in reality he will be among the dwellers of Hellfire”. The people think that he is righteous, but in his heart is an impurity and therefore he will be among the dwellers of Hellfire.