Bhagavad Gita: Chapter 17, Verse 4

यजन्ते सात्त्विका देवान्यक्षरक्षांसि राजसा: |
प्रेतान्भूतगणांश्चान्ये यजन्ते तामसा जना: || 4||

yajante sāttvikā devān yakṣha-rakṣhānsi rājasāḥ
pretān bhūta-gaṇānśh chānye yajante tāmasā janāḥ

yajanteworship; sāttvikāḥthose in the mode of goodness; devāncelestial gods; yakṣhasemi-celestial beings who exude power and wealth; rakṣhānsipowerful beings who embody sensual enjoyment, revenge, and wrath; rājasāḥthose in the mode of passion; pretān-bhūta-gaṇānghosts and spirits; chaand; anyeothers; yajanteworship; tāmasāḥthose in the mode of ignorance; janāḥpersons

yajante sattvika devan yaksha-rakshansi rajasah
pretan bhuta-ganansh chanye yajante tamasa janah

Translation

BG 17.4: Those in the mode of goodness worship the celestial gods; those in the mode of passion worship the yakṣhas and rākṣhasas; those in the mode of ignorance worship ghosts and spirits.

Commentary

It is said that the good are drawn to the good and the bad to the bad. Those in tamo guṇa are drawn toward ghosts and spirits, despite the evil and cruel nature of such beings. Those who are rājasic get drawn to the yakṣhas (semi-celestial beings who exude power and wealth) and rākṣhasas (powerful beings who embody sensual enjoyment, revenge, and wrath). They even offer the blood of animals to appease these lower beings, with faith in the propriety of such lowly worship. Those who are imbued with sattva guṇa become attracted to the worship of celestial gods in whom they perceive the qualities of goodness. However, worship is perfectly directed when it is offered to God.