Bhagavad Gita · 4.7
यदा यदा हि धर्मस्य ग्लानिर्भवति भारत।अभ्युत्थानमधर्मस्य तदात्मानं सृजाम्यहम्॥
yadā yadā hi dharmasya glānir bhavati bhārata abhyutthānam adharmasya tadātmānaṁ sṛijāmy aham
Whenever there is a decline of righteousness and a rise of unrighteousness, O Arjuna, at that time I manifest Myself.
— Bhagavad Gita 4.7
Source: Sacred-Texts.com (Sanskrit) + Bhagavad-Gita.io (translations)