The Buddha recounts the inquiry that led to the development of the four bases of psychic ability before his full awakening.

Pubba sutta - Before

At Sāvatthi.

"Bhikkhus, before my full awakening, while I was still only an unenlightened Bodhisatta, this thought occurred to me: 'What is the cause, what is the condition for the development of the bases of psychic ability?' Then, bhikkhus, it occurred to me: 'Here, a bhikkhu develops the basis of psychic ability that is endowed with collectedness arising from aspiration and accompanied by intentional effort my aspiration will not be too slack, nor too tense, and it will not be inwardly inhibited nor outwardly scattered. He dwells continuously aware as before, so after; as after, so before; as below, so above; as above, so below; as by day, so by night; as by night, so by day. In this way, with an open and unenveloped mind, he develops a mind that is radiant.'

Similarly, a bhikkhu develops the basis of psychic ability that is endowed with collectedness arising from energy and accompanied by intentional effort my energy will not be too slack, nor too tense, and it will not be inwardly inhibited nor outwardly scattered. He dwells continuously aware as before, so after; as after, so before; as below, so above; as above, so below; as by day, so by night; as by night, so by day. In this way, with an open and unenveloped mind, he develops a mind that is radiant.

Similarly, a bhikkhu develops the basis of psychic ability that is endowed with collectedness arising from [purification of] mind and accompanied by intentional effort my mind will not be too slack, nor too tense, and it will not be inwardly inhibited nor outwardly scattered. He dwells continuously aware as before, so after; as after, so before; as below, so above; as above, so below; as by day, so by night; as by night, so by day. In this way, with an open and unenveloped mind, he develops a mind that is radiant.

Similarly, a bhikkhu develops the basis of psychic ability that is endowed with collectedness arising from investigation and accompanied by intentional effort—my investigation will not be too slack, nor too tense, and it will not be inwardly inhibited nor outwardly scattered. He dwells continuously aware as before, so after; as after, so before; as below, so above; as above, so below; as by day, so by night; as by night, so by day. In this way, with an open and unenveloped mind, he develops a mind that is radiant.

When these four bases of psychic ability have been developed and frequently practiced in this way, one experiences various kinds of psychic abilities: being one, one becomes many; being many, one becomes one; one appears and disappears; one passes through walls, enclosures, and mountains as though through space; one dives in and out of the earth as though it were water; one walks on water without sinking as though on solid ground; one flies through the air cross-legged like a bird with wings; one touches and strokes with one's hand the sun and moon, so mighty and powerful; and one controls the body as far as the Brahmā world.

When these four bases of psychic ability have been developed and frequently practiced in this way, with the purified divine ear surpassing the human, one hears both kinds of sounds: divine and human, far and near.

When these four bases of psychic ability have been developed and frequently practiced in this way, one understands the minds of other beings, other persons, having encompassed them with one's own mind. One knows a mind with lust as 'with lust,' and a mind without lust as 'without lust'; a mind with hate as 'with hate,' and a mind without hate as 'without hate'; a mind with delusion as 'with delusion,' and a mind without delusion as 'without delusion'; a contracted mind as 'contracted,' and a distracted mind as 'distracted'; a developed mind as 'developed,' and an undeveloped mind as 'undeveloped'; a surpassable mind as 'surpassable,' and an unsurpassable mind as 'unsurpassable'; a collected mind as 'collected,' and an uncollected mind as 'uncollected'; a liberated mind as 'liberated,' and an unliberated mind as 'unliberated.'

When these four bases of psychic ability have been developed and frequently practiced in this way, one recollects their manifold past lives: one birth, two births, three births, four births, five births, ten births, twenty births, thirty births, forty births, fifty births, a hundred births, a thousand births, a hundred thousand births; many cycles of [universal] contraction, many cycles of [universal] expansion, many cycles of [universal] contraction and expansion: 'There I was so named, of such a clan, with such an appearance, such was my food, such was my experience of pleasure and pain, such was my life span; and passing away from there, I was reborn elsewhere; and there too I was so named, of such a clan, with such an appearance, such was my food, such was my experience of pleasure and pain, such was my life span; and passing away from there, I was reborn here.' Thus with their aspects and particulars, one recollects their manifold past lives.

When these four bases of psychic ability have been developed and frequently practiced in this way, with the purified divine eye surpassing the human, one sees beings passing away and reappearing, inferior and superior, fair and ugly, fortunate and unfortunate, and one understands how beings pass on according to their actions thus: 'These beings, who were endowed with bad conduct of body, speech, and mind, who reviled the Noble Ones, held wrong views and undertook actions under the influence of wrong view, with the breakup of the body, after death, have reappeared in a state of deprivation, in an unhappy destination, in perdition, even in hell. But these beings, who were endowed with good conduct of body, speech, and mind, who did not revile the Noble Ones, who held right view and undertook actions under the influence of right view, with the breakup of the body, after death, have reappeared in a good destination, in a heavenly world.' Thus with the purified divine eye surpassing the human, one sees beings passing away and reappearing, inferior and superior, fair and ugly, fortunate and unfortunate, and understands how beings pass on according to their actions.

When these four bases of psychic ability have been developed and frequently practiced in this way, through the wearing away of the taints, one realizes for themselves with direct knowing, in this very life, the taintless liberation of mind, liberation by wisdom, and having entered upon it, dwells in it."