After God taught me to develop the gift of discerning of spirits (defined in the previous chapter), I needed to understand what to do when I discerned the presence of spirits. Do I always cast out the spirits, as frequently described in scriptures and writings of early LDS leaders? The answer from God was a very strong NO! Casting out spirits does not help them and only sends them to torment some other unsuspecting mortal. A much more productive solution is to help the spirits so that they accept Jesus as their savior, repent, and receive forgiveness from their sins so they can progress eternally.
As I began to use the gift of discerning of spirits, I was unclear which spirits could be helped once I discerned their presence. I assumed that evil spirits (those who followed Satan in the premortal life) could not be helped, but I was wrong in this assumption. Chapters 12 through 14 discuss helping evil spirits. So what about unclean spirits, those who have lived and died and are currently in a state of spiritual prison in the spirit world?
I have a declaration to make in relation to the provisions which God made for every creature from before the foundation of the world to suit the conditions of man. What has Jesus said? All sins and all blasphemies—every transgression that man may be guilty of—shall be forgiven in this world or the world to come, except one—the sin against the Holy Ghost. There is a provision for salvation for him, either in this world or in the world of spirits which is to me. Hence, God has made a provision that the spirits of our friends and every spirit in that eternal world can be ferreted out and saved, unless he has committed that unpardonable sin which can’t be remitted to him, whether in this world or in the world of spirits. God has wrought out salvation for all men, unless they have committed a certain sin. Every man who has got a friend in the eternal world can save him, unless he has committed the unpardonable sin. You can save any man who has not committed the unpardonable sin. So you see how far you can be a savior.
A man cannot commit the unpardonable sin after the dissolution of the body. He cannot be damned through all eternity; there is a way possible for his escape in a little time, so he is not particularly damned. If a man has knowledge he can be saved, for knowledge saves a man. There are those that are without wisdom until they get exalted to wisdom, and in the world of spirits there is no way for a man to come to understanding and be exalted but by knowledge. If he has been guilty of great sins, he is punished for them. So long as a man will not give consent and heed to the commandments, he must abide without salvation. When he consents to obey the Gospel, whether alive or dead, he is saved. …
I know the Scriptures; I understand them. I said that no man can commit the unpardonable sin after the dissolution of the body. Why? Because they must commit the unpardonable sin in this world after they receive the Holy Ghost. All will suffer in the eternal world until they obey Christ himself and are exalted. …
All sin shall be forgiven, except the sin against the Holy Ghost, for Jesus Christ will save all except the sons of perdition. What must a man do to commit the unpardonable sin? He has got to deny the plan of salvation; he has got to say that the sun does not shine while he sees it with his eyes open; he has got to receive the Holy Ghost, deny Jesus Christ when the heavens are open to him, know God, and then sin against Him. After a man has sinned the sin against the Holy Ghost, there is no repentance for him.
Joseph Smith, “The King Follett Discourse: a Newly Amalgamated Text” by Stan Larson, BYU Studies, vol. 18 (1977-1978), Number 2 - Winter 1978, 205-06.