BaZi doesn't belong to any religion, but it's compatible with many.
Daoism: BaZi grew from Daoist cosmology — the Five Elements, Yin-Yang, and qi theory are Daoist concepts. Daoists often use BaZi as a practical tool for understanding one's nature and timing, alongside practices like meditation and inner alchemy.
Buddhism: The Buddha didn't teach BaZi, but many Buddhist cultures (especially Chinese and Tibetan) integrated metaphysical systems without conflict. Buddhism emphasizes that karma and mind transcend any chart — BaZi shows temporary conditions, not ultimate nature.
Other religions: BaZi requires no worship, no doctrine, no exclusivity. It's a descriptive system, not a prescriptive belief. You can practice Christianity, Islam, Judaism, or any other faith and still learn from your chart.
If your religion forbids divination, simply reframe BaZi as personality analysis and timing strategy — which is what it actually is.