Ānanda explains to the brahmin Uṇṇābha how desire is abandoned by developing the four bases of psychic ability.
Uṇṇābhabrāhmaṇa sutta - The Brahmin Uṇṇābha
"Thus have I heard - At one time, the Venerable Ānanda was dwelling in Kosambi, at Ghositā's park. Then the brahmin Uṇṇābha approached the Venerable Ānanda. Having approached, he exchanged greetings with the Venerable Ānanda. After exchanging friendly and courteous greetings, he sat down to one side. Seated to one side, the brahmin Uṇṇābha said to the Venerable Ānanda: "friend Ānanda, for what purpose is the spiritual life lived under the ascetic Gotama?"
"Brahmin, it is for the purpose of abandoning desire that the spiritual life is lived under the Blessed One."
"But, friend Ānanda, is there a path, is there a way to abandon this desire?"
"Yes, brahmin, there is a path, there is a way to abandon this desire."
"What, then, is the path, what is the way to abandon this desire?"
"Here, brahmin, a bhikkhu develops the basis of psychic ability that is endowed with collectedness arising from desire and accompanied by intentional effort; develops the basis of psychic ability that is endowed with collectedness arising from energy and accompanied by intentional effort; develops the basis of psychic ability that is endowed with collectedness arising from [purification of] mind and accompanied by intentional effort; and develops the basis of psychic ability that is endowed with collectedness arising from investigation and accompanied by intentional effort. This, brahmin, is the path, this is the way to abandon this desire."
"In that case, friend Ānanda, it would be impossible to abandon desire by means of desire itself."
"Then, brahmin, I will ask you a question. Answer as you see fit. What do you think, brahmin: Did you earlier have the desire, 'I will go to the park,' and now that you have come to the park, has that desire you had before to come to the park been abandoned?"
"Yes, sir."
"Did you earlier arouse energy, thinking, 'I will go to the park,' and now that you have come to the park, has that energy you had before to come to the park been abandoned?"
"Yes, sir."
"Did you earlier resolve in your mind, 'I will go to the park,' and now that you have come to the park, has that resolution in the mind you had before to come to the park been abandoned?"
"Yes, friend Ānanda."
"Did you earlier make an investigation, 'Shall I go to the park?' and now that you have come to the park, has that investigation you had before to come to the park been abandoned?"
"Yes, sir."
"In the same way, brahmin, when a bhikkhu is an arahant, one whose taints have been exhausted, who has lived the spiritual life, done what had to be done, laid down the burden, attained his own goal, utterly exhausted the fetters of existence, and is completely liberated through final knowledge, the desire that he had before for the attainment of arahantship is abandoned once arahantship is attained. The energy that he had aroused before for the attainment of arahantship is abandoned once arahantship is attained. The resolution in the mind that he had before for the attainment of arahantship is abandoned once arahantship is attained. The investigation that he had made before for the attainment of arahantship is abandoned once arahantship is attained. What do you think, brahmin, such being the case, does the [path] have an end or is it endless?"
"Indeed, friend Ānanda, in such a case, the [path] has an end, it is not endless. Excellent, friend Ānanda, excellent. Just as if one might set upright what had been overturned, reveal what had been concealed, point out the way to one who was lost, or hold up a lamp in the dark so that those with eyes could see forms, in the same way, friend Ānanda, the Dhamma has been explained by you in many ways. I go for refuge to venerable Gotama, to the Dhamma, and to the community of bhikkhus. May venerable Ānanda remember me as a lay follower who, from this day forward, has gone to refuge for life."