The Buddha explains the proximate causes for the ending of defilements. The twelve factors leading to the ending of defilements are explained along with twelve factors that lead to suffering.

Upanisa sutta - Proximate Causes

At Sāvatthi.

"I declare, bhikkhus, the ending of defilements for one who knows and sees, not for one who does not know and does not see. And what, bhikkhus, does one know and see for the ending of defilements to occur? 'Such is form, such is the arising of form, such is the dissolution of form; such is feeling, such is the arising of feeling, such is the dissolution of feeling; such is perception, such is the arising of perception, such is the dissolution of perception; such are formations, such is the arising of formations, such is the dissolution of formations; such is consciousness, such is the arising of consciousness, such is the dissolution of consciousness.' This is how, bhikkhus, for one who knows and sees in this way, the ending of defilements occurs.

"I declare the knowledge of ending with its proximate cause, not without. And what, bhikkhus, is the proximate cause of knowledge of ending? 'Release' should be said. Indeed, bhikkhus, I declare release with its proximate cause, not without. And what, bhikkhus, is the proximate cause of release? 'Dispassion' should be said. Indeed, bhikkhus, I declare dispassion with its proximate cause, not without. And what, bhikkhus, is the proximate cause of dispassion? 'Disenchantment' should be said. Indeed, bhikkhus, I declare disenchantment with its proximate cause, not without. And what, bhikkhus, is the proximate cause of disenchantment? 'Knowledge and vision of things as they have come to be' should be said. Indeed, bhikkhus, I declare knowledge and vision of things as they have come to be with its proximate cause, not without. And what, bhikkhus, is the proximate cause of knowledge and vision of things as they have come to be? 'Collectedness' should be said. Indeed, bhikkhus, I declare collectedness with its proximate cause, not without."

And what, bhikkhus, is the proximate cause for collectedness? 'Ease' should be said. Indeed, bhikkhus, I declare ease to be with proximate cause, not without proximate cause. And what, bhikkhus, is the proximate cause for ease? 'Tranquility' should be said. Indeed, bhikkhus, I declare tranquility to be with proximate cause, not without proximate cause. And what, bhikkhus, is the proximate cause for tranquility? 'Rapture' should be said. Indeed, bhikkhus, I declare rapture to be with proximate cause, not without proximate cause. And what, bhikkhus, is the proximate cause for rapture? 'Joy' should be said. Indeed, bhikkhus, I declare joy to be with proximate cause, not without proximate cause. And what, bhikkhus, is the proximate cause for joy? 'Faith' should be said. Indeed, bhikkhus, I declare faith to be with proximate cause, not without proximate cause.

And what, bhikkhus, is the proximate cause for faith? 'Suffering' should be said. Indeed, bhikkhus, I declare suffering to be with proximate cause, not without proximate cause. And what, bhikkhus, is the proximate cause for suffering? 'Birth' should be said. Indeed, bhikkhus, I declare birth to be with proximate cause, not without proximate cause. And what, bhikkhus, is the proximate cause for birth? 'Continued existence' should be said. Indeed, bhikkhus, I declare continued existence to be with proximate cause, not without proximate cause. And what, bhikkhus, is the proximate cause for continued existence? 'Clinging' should be said. Indeed, bhikkhus, I declare clinging to be with proximate cause, not without proximate cause. And what, bhikkhus, is the proximate cause for clinging? 'Craving' should be said. Indeed, bhikkhus, I declare craving to be with proximate cause, not without proximate cause.

And what, bhikkhus, is the proximate cause for craving? 'Feeling' should be said... 'Contact' should be said... 'The six sense bases' should be said... 'Name and Form' should be said... 'Consciousness' should be said... 'Formations' should be said. Indeed, bhikkhus, I declare formations to be with proximate cause, not without proximate cause. And what, bhikkhus, is the proximate cause for formations? 'Ignorance' should be said.

Thus, bhikkhus, ignorance is the proximate cause for formations, formations are the proximate cause for consciousness, consciousness is the proximate cause for name-and-form, name-and-form is the proximate cause for the six sense bases, the six sense bases are the proximate cause for contact, contact is the proximate cause for feeling, feeling is the proximate cause for craving, craving is the proximate cause for clinging, clinging is the proximate cause for continued existence, continued existence is the proximate cause for birth, birth is the proximate cause for suffering, suffering is the proximate cause for faith, faith is the proximate cause for joy, joy is the proximate cause for rapture, rapture is the proximate cause for tranquility, tranquility is the proximate cause for ease, ease is the proximate cause for collectedness, collectedness is the proximate cause for knowledge and vision of things as they have come to be, knowledge and vision of things as they have come to be is the proximate cause for disenchantment, disenchantment is the proximate cause for dispassion, dispassion is the proximate cause for release, and release is the proximate cause for the knowledge of ending.

Just as, bhikkhus, when a great downpour occurs atop a mountain, the cascading water naturally progresses, filling up the mountain's hollows, gullies, and crevices. These, once filled, replenish the small ponds. The small ponds, upon reaching their capacity, replenish the larger ponds. The larger ponds, once full, replenish the streams. The streams, having been replenished, fill the rivers. The rivers, upon being filled, replenish the great ocean.

In the same way, bhikkhus, ignorance is the proximate cause for formations, formations are the proximate cause for consciousness, consciousness is the proximate cause for name-and-form, name-and-form is the proximate cause for the six sense bases, the six sense bases are the proximate cause for contact, contact is the proximate cause for feeling, feeling is the proximate cause for craving, craving is the proximate cause for clinging, clinging is the proximate cause for continued existence, continued existence is the proximate cause for birth, birth is the proximate cause for suffering, suffering is the proximate cause for faith, faith is the proximate cause for joy, joy is the proximate cause for rapture, rapture is the proximate cause for tranquility, tranquility is the proximate cause for ease, ease is the proximate cause for collectedness, collectedness is the proximate cause for knowledge and vision of things as they have come to be, knowledge and vision of things as they have come to be is the proximate cause for disenchantment, disenchantment is the proximate cause for dispassion, dispassion is the proximate cause for release, and release is the proximate cause for the knowledge of ending.