When your mind is not clear…
you may well take a thief
to be your own child.
- The Buddha (Surangama Sutra)
When you practice meditation in stillness and enter samadhi, the essence of your mind merges with the Bodhisattvas of the ten directions and with the minds of all the great Arhats, who have ended outflows. You abide in a place of profound purity. Then the kings of demons, ghosts, an spirits and the general population of gods see their palaces collapse inexplicably. Their lands quake. Terror strikes the creatures who move through water, on land, and in the air. Ordinary people, in the darkness of their confusion, know nothing of these events.
All these demonic beings have five spiritual powers; they lack only freedom from outflows because they are still attached to the stress of entanglement with perceived objects. How could they be happy with seeing their palaces destroyed? Celestial demons, shape-shifting ghosts, and succubus-demons will all come to disturb your samadhi. But despite their furious rage, they are subject to the stress of entanglement with perceived objects, while you abide within wondrous enlightenment. Therefore they can do you no harm any more than wind can blow light away or a knife cut water. You are like water at the boil, and they are like ice frozen solid as they come close to your warmth, they will melt. They have only their spiritual powers, so they can visit you only briefly. They cannot disturb you except though your mind, which is the host of the five aggregates. Only when the innkeeper is befuddled can his guests do as they please.
When you are absorbed in meditation, fully awake and free of delusion, how will the deeds of these demons be able to affect you? For you, the five aggregates will have been dissolved, and you will have entered into the light of understanding. These deviant hordes rely upon dark energy, and your light will overcome their darkness. If they come near you, they will be destroyed. How will they dare to linger and try to disrupt your samadhi? But if you have not awakened to the light of understanding and are confused by the five aggregates, Ananda, you yourself could become a disciple of demons and could turn into a demon yourself.
The Surangama Sutra
Buddhist Text Translation Society