Bhagavad Gita · 17.4
यजन्ते सात्त्विका देवान्यक्षरक्षांसि राजसाः।प्रेतान्भूतगणांश्चान्ये यजन्ते तामसा जनाः॥
yajante sāttvikā devān yakṣha-rakṣhāṁsi rājasāḥ pretān bhūta-gaṇāṁśh chānye yajante tāmasā janāḥ
Those in the mode of goodness worship the gods; those in the mode of passion worship powerful beings and demons; and those in the mode of ignorance worship ghosts and spirits.
— Bhagavad Gita 17.4
Source: Sacred-Texts.com (Sanskrit) + Bhagavad-Gita.io (translations)