Spiritual life is acquired solely by a life according to the commandments in the Word. These commandments are given in summary in the Decalogue, namely, Thou shalt not commit adultery, Thou shalt not steal, Thou shalt not kill, Thou shalt not bear false witness, Thou shalt not covet the goods of others. These commandments are the commandments that are to be done, for when a man does these his works are good and his life is spiritual, and for the reason that so far as a man shuns evils and hates them so far he wills and loves goods.
For there are two opposite spheres that surround man, one from hell, the other from heaven; from hell a sphere of evil and falsity therefrom, from heaven a sphere of good and of truth therefrom; and these spheres do [not immediately] affect the body, but they affect the minds of men, for they are spiritual spheres, and thus are affections that belong to the love. In the midst of these man is set; therefore so far as he approaches the one, so far he withdraws from the other. This is why so far as a man shuns evils and hates them, so far he wills and loves goods and the truths therefrom; for no one can at the same time serve two masters, for he will hate the one and will love the other. (Matthew 6:24).
But let it be noted, that man must do these commandments from religion, because they are commanded by the Lord; and if he does this from any other consideration whatever, for instance, from regard merely to the civil law or the moral law, he remains natural, and does not become spiritual. For when a man acts from religion, he acknowledges in heart that there is a God, a heaven and a hell, and a life after death. But when he acts from regard merely to the civil and moral law, he may act in the same way, and yet in heart may deny that there is a God, a heaven and a hell, and a life after death. And if he shuns evils and does goods, it is merely in the external form, and not in the internal; thus while he is outwardly in respect to the life of the body like a Christian, inwardly in respect to the life of his spirit he is like a devil. All this makes clear that a man can become spiritual, or receive spiritual life, in no other way than by a life according to religion from the Lord.
I have had proof that this is true from angels of the third or inmost heaven, who are in the greatest wisdom and happiness. When asked how they had become such angels, they said it was because during their life in the world they had regarded filthy thoughts as abominable, and these had been to them adulteries; and had regarded in like manner frauds and unlawful gains, which had been to them thefts; also hatreds and revenges, which had been to them murder; also lies and blasphemies, which had been to them false testimonies; and so with other things. When asked again whether they had done good works, they said they loved chastity, in which they were because they had regarded adulteries as abominable; that they loved sincerity and justice, in which they were because they had regarded frauds and unlawful gains as abominable; that they loved the neighbor because they had regarded hatreds and revenges as abominable; that they loved truth because they had regarded lies and blasphemies as abominable, and so on; and that they perceived that when these evils have been put away, and they acted from chastity, sincerity, justice, charity and truth, it was not done from themselves, but from the Lord, and thus that all things whatsoever that they had done from these were good works, although they had done them as if from themselves; and that it was on this account that they had been raised up by the Lord after death into the third heaven. Thus it was made clear how spiritual life, which is the life of the angels of heaven, is acquired.
from Spiritual Life and the Word of God, Part First