All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
The matter of the Hereafter is in the Hands of Allaah, He is the All-Knowing, the All-Wise, and He weighs with even and honest scales, which are the scales of justice, and no one is wronged by Him. Allaah says (what means): {And We place the scales of justice for the Day of Resurrection, so no soul will be treated unjustly at all. And if there is [even] the weight — of a mustard seed, We will bring it forth. And sufficient are We as accountant.}[Quran 21:47]
If a person dies as a Muslim and people do not know that he embraced Islam, then Allaah Knows about him and He will forgive him with His Mercy and make him enter His Paradise. Allaah says (what means): {What would Allaah do with [i.e. gain from] your punishment if you are grateful and believe? And ever is Allaah Appreciative and Knowing.}[Quran 4:147]
People, on the other hand, would treat him according to what they know about him: if they do not know that he had uttered the Two Testimonies of Faith and embraced Islam, then they deal with him in this worldly life as a non-Muslim. If he dies, he is not washed or enshrouded and he is not buried in the Muslim graveyards, and it is not permissible to supplicate for him or seek forgiveness for him.
Abu Hurayrah narrated that the Prophet said: "By Him in Whose Hand the soul of Muhammad is, there is no Jew or Christian of this Ummah who hears about me and then dies without believing in what I was sent with, except that he will be among the people of Hellfire.” [Muslim]
What it means to 'hear' the Prophet as mentioned in the Hadeeth, was interpreted by some scholars to mean that a person knows about the Prophet’s message and knows that he was sent by Allaah to people.
Al-Qaari said: “It means: If anyone, who is present or will be present, hears someone else tell about me being sent as a Prophet, or in short, if anyone knows about my message, "from this Ummah," - that is, from 'the Ummah that was preached the message, i.e. that includes all people who heard of the Prophet ]....”
For more benefit, please refer to Fatwa 90888.
Nevertheless, some scholars are of the view that just hearing that he was sent as a prophet is not enough to judge that the person will be eternally in Hellfire even though anyone who does not believe in the Prophet Muhammad is called a non-Muslim and in this world, the legal status of a non-Muslim applies to him; however, if the Message did not reach him in a correct, undistorted and unaltered manner, then he is excused in the sight of Allaah, and his ruling is the ruling of the people whom the message did not reach, and he will be tested on the Day of Judgment.
Shaykh Al-Albaani said: “If the message of Islam reached the people in a forged manner…altered…changed, especially as relates to its principles and creed, then, I am the first one to say that the message has not reached such people, because what is meant by the message having reached them, is the pure clear message; but if we presume that the message had reached them in a distorted altered manner, then the message did not reach such people, and so, the evidence of Allaah against them is not established.”
Allaah Knows best.