This is Lord of Light (1967) by Roger Zelazny.
Lord of Light is set on a planet colonized by some of the remnants of "vanished Urath", or Earth. The crew and colonists from the spaceship Star of India found themselves on a strange planet surrounded by hostile indigenous races and had to carve a place for themselves or perish. To increase their chances of survival, the crew has used chemical treatments, biofeedback and electronics to mutate their minds and create enhanced self-images, or "Aspects", that "strengthened their bodies and intensified their wills and extended the power of their desires into Attributes, which fell with a force like magic upon those against whom they were turned." The crew has also developed a technology to transfer a person's atman, or soul, electronically to a new body. This reincarnation by mind transfer has created a race of potential immortals and allowed the former crew members to institute the Hindu caste system, with themselves at the top.
Agni (and various other Hindu deities) make an appearance in the fourth chapter/story
Sam enters Hellwell, a huge pit where he had bound the demons centuries earlier. He negotiates with their leader, Taraka, for allies in his struggle. Soon after, Agni, God of Fire, arrives to kill Sam, finding instead two spirits in one body. Agni destroys the palace, while Sam/Taraka flees to Hellwell. They decide to free as many demons as possible before the gods arrive. However, even the full might of all the demons of Hellwell cannot stand against the gods.