The core teaching is stated plainly in Kiddushin 30b:4-6 and its parallel in Sifrei Devarim 45: God tells Israel that He created the evil inclination, which is the wound, and created Torah as its tavlin (antidote) — one who engages in Torah study is not handed over to the yetzer hara's power, while one who abandons Torah study falls under its dominion, drawing on the pasuk 'sin crouches at the door' and 'yet you can rule over it.' The same formula is cited again in Bava Batra 16a:13, answering Job's friends, and in Kli Yakar on Vayikra 23:16, who connects it to the chametz in the two loaves of Shavuot as a symbol of the yetzer that Torah neutralizes.
Mesillat Yesharim 5:7-9 draws out the practical force of this teaching: since the Creator provided only this one remedy for the affliction of the yetzer hara, it is impossible for a person to be healed from it by any other means, and one who imagines he can save himself without Torah study is simply mistaken, a mistake he discovers only when he dies in sin.
Chiddushei Aggadot, Kiddushin 30 and Nefesh HaChayim, Gate IV 31:10-11 develop how the antidote actually works: engaging in Torah protects a person from the yetzer's control, and drawing near to Torah draws a person near to the Holy One, while one who distances himself from Torah distances himself from God — citing teachings that one beset by evil thoughts should turn to the study hall, and that the light within Torah itself restores a person to the good. Nefesh HaChayim, Gate IV 17:12 adds that engagement in Torah saves a person from three judgments, including that of the Angel of Death, since words of Torah themselves shield one from it.
Several sources describe the mechanism as an ongoing battle rather than a single victory: Berakhot 5a:2 teaches that a person should first arouse the good inclination against the evil one, and only if that fails turn to Torah study (and, per Chiddushei Aggadot, Sanhedrin 44, if even that does not suffice, recite the Shema). Tanya, Part I; Likkutei Amarim 29:19-20 elaborates this by describing the forceful inner rebuke of the animal soul called for in that same teaching, and Tanya, Part I; Likkutei Amarim 27:6-8 and Tanya, Part I; Likkutei Amarim 30:10-12 frame the lifelong struggle against the yetzer as the very purpose of a person's service, requiring real exertion in Torah study beyond one's natural inclination. Tanya, Part I; Likkutei Amarim 35:1 further explains that even the beinoni cannot banish the animal soul entirely but must continually suppress it.
Rav Kook (Ein Aya, Berakhot 1:24) reads the same teaching of rousing the good against the evil inclination as meaning that one's good and evil powers are not to be weakened but properly ordered, with the good powers ruling, and Torah study is what instills the beauty of the good path in one whose soul is not yet refined enough to sense it on its own.
Shem MiShmuel, Nasso 6:6 distinguishes different forms the yetzer hara can take in a person — residing in different organs and functioning as an inner adversary that confuses good and bad — and states that the remedy for each is engagement in Torah, since Torah is what clarifies between the fit and the unfit within a person's heart and thereby repels these forces; this is why, he notes, Israel was given some portions of Torah at Marah before Sinai.
Eretz Tzvi Moadim p. 152 reads the 'tavlin' specifically as a preventive remedy, protecting against future sin rather than only curing sin already committed, while Eretz Tzvi Moadim p. 153 distinguishes two different modes of the yetzer hara — deceiving a person into viewing a sin as a mitzvah, versus intensifying desire for a recognized sin — contrasting both with being a source of strength and light.
Peri Tzadik, Vayetzei 2:2 qualifies the remedy, noting that even Torah study alone is not sufficient against the yetzer hara without God's own assistance, since the yetzer intensifies itself daily beyond what was implanted at a person's creation.
Tehillim 119:9-11 supplies the Scriptural model behind this teaching: a young man keeps his way pure by guarding it according to God's word, seeking Him with his whole heart, and hiding His word in his heart precisely so as not to sin — the same pattern of Torah as a safeguard against the yetzer that the Gemara later formalizes.
Mishneh Torah, Human Dispositions 6:1 and Mishneh Torah, Torah Study 3:13 extend this practically: a person is naturally drawn after his companions and should therefore attach himself to the wise and distance himself from the wicked, and one who wishes to merit the crown of Torah should devote his nights to Torah study rather than idle pursuits, both serving as concrete disciplines through which the antidote of Torah is actually applied.
Rav Eliezer Melamed (Peninei Halakhah, Days of Awe 6:11) applies the idea to teshuvah, teaching that a person naturally follows his evil inclinations toward quick gratification and becomes enslaved to them, and that through repentance and through Torah, which guides a person in the path of truth, the soul is freed from the bonds of the yetzer.
Mesillat Yesharim 1:7-8 frames the broader setting of this struggle, describing man as placed by God in the midst of constant trial, surrounded by physical desires that draw him from the true good, so that all worldly matters, for good or bad, become tests of this battle.
Tanna DeBei Eliyahu Rabbah:16 adds a striking element, that God Himself is described as regretting having created the yetzer hara, wondering what benefit came from it, which opens the door for sinners to plead for mercy and repentance.