The pain and anxiety comes from spirits
Arcana Coelestia 6368… man of himself is in hell, for his will and thought from his own is nothing but evil and its falsity, by which he has been so bound to hell that he cannot be torn away without violence. This tearing away and deliverance is what is called the “prey;” and because this is done from the Lord’s Divine good, it is said that from the Lord through what is celestial is the deliverance of many from hell.
4496… when a man is being purified from these loves, as is the case when he is being regenerated, he is in pain and anxiety, and it is the cupidities then being removed which are in pain and anguish.
AC4249… when good is taking the prior place and is subordinating truths to itself, which takes place when the man is undergoing spiritual temptations, the good that then flows in from within is attended with very many truths which have been stored up in his interior man. These cannot come to his mental view and apprehension until good acts the first part, for then the natural begins to be enlightened by good, whence it becomes apparent what things in it are in accord, and what are discordant, from which come the fear and distress that precede spiritual temptation. For spiritual temptation acts upon the conscience, which is of the interior man; and therefore when he enters into this temptation the man does not know whence come such fear and distress, although the angels with him know this well; for the temptation comes from the angels holding the man in goods and truths while evil spirits are holding him in evils and falsities.
 For the things that come forth with the spirits and angels who are with a man are perceived by the man exactly as if they were in him; for while a man is living in the body, and does not believe that all things flow in, he supposes that the things which come forth interiorly are not produced by causes outside of him, but that all the causes are within him, and are his very own; yet such is not the case. For whatever a man thinks and whatever he wills (that is, his every thought and his every affection) are either from hell or from heaven. When he thinks and wills evils, and is delighted with the consequent falsities, he may know that his thoughts and affections are from hell; and while he is thinking and willing goods, and is delighted with the derivative truths, he may know that they are from heaven, that is, through heaven from the Lord. But the thoughts and affections that appertain to a man appear for the most part under another aspect; as for example, the combat of evil spirits with angels that arises from the things which appertain to a man who is to be regenerated, appears under the aspect of fear and distress, and of temptation.
 These statements cannot but appear to man as paradoxes, because almost every man of the church at this day believes that all the truth which he thinks, and the good which he wills and does, are from himself, although he says otherwise when he speaks from the doctrine of faith. Nay, of such a nature is man that if anyone should say to him that there are evil spirits from hell who are flowing into his thought and will when he thinks and wills evils, and angels from heaven when he thinks and wills goods, he would stand amazed that anyone should maintain such a thing; for he would say that he feels life in himself, and thinks from himself and wills from himself. From this feeling in himself he forms his belief, and not from his doctrine; when yet the doctrine is true, but the feeling fallacious. It has been given me to know this from an almost continual experience of many years, and so to know it that no doubt whatever remains.
HH99. I have also been permitted to learn the source of human anxiety, grief of mind, and interior sadness, which is called melancholy. There are spirits not as yet in conjunction with hell, because they are in their first state; these will be described hereafter when treating of the world of spirits. Such spirits love things undigested and pernicious, such as pertain to food becoming foul in the stomach; consequently they are present with man in such things because they find delight in them; and they talk there with one another from their own evil affection. The affection that is in their speech flows in from this source into man; and when this affection is the opposite of man’s affection there arises in him sadness and melancholy anxiety; but when it agrees with it it becomes in him gladness and cheerfulness. These spirits appear near to the stomach, some to the left and some to the right of it, and some beneath and some above, also nearer and more remote, thus variously in accordance with their affections. That this is the source of anxiety of mind has been shown and proved to me by much experience. I have seen these spirits, I have heard them, I have felt the anxieties arising from them, and I have talked with them; when they have been driven away the anxiety ceased; when they returned the anxiety returned; and I have noted the increase and decrease of it according to their approach and removal. From this it has been made clear to me why some who do not know what conscience is, because they have no conscience, ascribe its pangs to the stomach.
The equilibrium between heaven and hell
Heaven and Hell 592. Unless the Lord ruled both the heavens and the hells there would be no equilibrium; and if there were no equilibrium there would be no heaven or hell; for all things and each thing in the universe, that is, both in the natural world and in the spiritual world, endure by means of equilibrium. Every rational man can see that this is true. If there were a preponderance on one part and no resistance on the other would not both perish? So would it be in the spiritual world if good did not react against evil and continually restrain its uprising; and unless this were done by the Divine Itself both heaven and hell would perish, and with them the whole human race. It is said unless the Divine Itself did this, because the self of everyone, whether angel, spirit, or man, is nothing but evil (see above, 591); consequently neither angels nor spirits are able in the least to resist the evils continually exhaling from the hells, since from self they all tend towards hell. It is evident, then, that unless the Lord alone ruled both the heavens and the hells no one could ever be saved. Moreover, all the hells act as one; for evils in the hells are connected as goods are in the heavens; and the Divine alone, which goes forth solely from the Lord, is able to resist all the hells, which are innumerable, and which act together against heaven and against all who are in heaven.
593. The equilibrium between the heavens and the hells is diminished or increased in accordance with the number of those who enter heaven and who enter hell; and this amounts to several thousands daily. The Lord alone, and no angel, can know and perceive this, and regulate and equalize it with precision; for the Divine that goes forth from the Lord is omnipresent, and sees everywhere whether there is any wavering, while an angel sees only what is near himself, and has no perception in himself of what is taking place even in his own society.
594.How all things are so arranged in the heavens and in the hells that each and all of those who are there may be in their equilibrium, can be in some measure confirmed from the things said and shown above respecting the heavens and the hells, namely, that all the societies of heaven are most distinctly arranged in accordance with goods and their kinds and varieties, and all the societies of hell in accordance with evils, and their kinds and varieties; and that beneath each society of heaven there is a society of hell corresponding to it from opposition, and from this opposing correspondence equilibrium results; and in consequence of this the Lord unceasingly provides that no infernal society beneath a heavenly society shall gain any preponderance, and as soon as it begins to do so it is restrained by various means, and is reduced to an exact measure of equilibrium. These means are many, only a few of which are to be noted. Some of these means have reference to the stronger presence of the Lord; some to the closer communication and conjunction of one or more societies with others; some to the casting out of superabundant infernal spirits into deserts; some to the transference of certain spirits from one hell to another; some to the reducing of those in the hells to order, and this also is effected in various ways; some to the screening of certain hells under denser and thicker coverings, also letting them down to greater depths; besides other means; and still others that are employed in the heavens above the hells. These things have been said that it may in some measure be perceived that the Lord alone provides that there is an equilibrium everywhere between good and evil, thus between heaven and hell; for on such equilibrium the safety of all in the heavens and of all in the earths rests.