Deeds Are Judged by Their Endings
historical noteShaykh Yasir Qadhi explains:
A famous story is authentically placed at Khaybar in Ṣaḥīḥ al-Bukhārī, though similar accounts appear at other battles, scholars differ whether narrators confused one incident or the like of it recurred. A Bedouin fought so mightily that the people marveled: this is a man of Jannah walking the earth. The Prophet ﷺ replied: rather, he is a man of Jahannam.
The companions were shaken, if such a fighter is bound for the Fire, who among us can hope for Paradise? One companion resolved to follow him and learn the truth of it. In time an arrow gashed the man's hand, ruining it; unable to fight on, he planted his sword in the ground and threw himself upon it. His fighting had never been fī sabīli Llāh, it was for honor, fame, and legacy, the warrior's hunger to be spoken of; and when that was taken from him, he ended his own life.
The observer returned declaring the shahādah anew, and the Prophet ﷺ taught: a person may do deeds that appear to the people as the deeds of the people of Jannah, yet the decree overtakes him and he dies upon a deed of the Fire; and a person may appear to do the deeds of the people of the Fire, yet the decree overtakes him and he ends upon a deed of Jannah. The lesson is the well-known principle: deeds are judged by their endings (الْأَعْمَالُ بِالْخَوَاتِيمِ), what matters is the state in which one dies.