Ghosts are an invention of the human imagination. They have no substance, and they do not have anything to do with us. They simply do not exist.
God has given us some information about the jinn, a type of creature given the same measure of free will as human beings, and are required to believe in the divine message given to the Prophet Muhammad (peace be upon him), as they were required to believe in the message given to Prophet Moses (peace be upon him). Like humans, most of them do not believe. Those of them who believe are good ones, and those who turn away from faith are bad ones, or satans. Their world is different from ours. They do not harm us as we do not harm them. We cannot see them, although they see us.
A verse in the Quran addresses the Prophet (peace be upon him) in this way: “They ask you about the spirit. Say: ‘(Knowledge of) the spirit belongs to my Lord.’ You have been given but scanty knowledge.” (17: 85)
Commentators explain that the spirit and how it functions are part of the realm that is beyond the reach of human perception. Hence, it is wrong for people to spend much time trying to obtain information when there is no reliable source to which they can resort.
Guided by this verse, I do not like to speak about the spirit, except within the limits of what we are told in the Quran or in authentic Hadiths. What we know is that a human being’s spirit splits from his body at the time of his death, and goes into a different stage of life. Where this takes place is unknown to us. However, the spirits of good believers are in a happy state, and those of unbelievers are in a miserable state.