The territory where this temple stands is known for the fact that natural gas comes out of the ground, when in contact with oxygen, a natural fire occurs. The structure that can be seen now was erected in the 17th and 18th centuries by the Hindu community from the Sikh caste. But the history of the temple is much older. Long before that, there was an ancient sanctuary of the Zoroastrians, who endowed fire with special, mystical properties and came to worship the shrine.
After Azerbaijan was conquered by the Arabs and the locals converted to Islam, the authorities destroyed the temple, and many fire worshippers were forced to leave for India. But in the 15th-17th centuries, fire-worshippers came here with caravans of traders, who began to make a pilgrimage to the site of the ancient sanctuary. Soon Indian merchants began to erect new buildings.
The earliest construction of the Ateshgah temple dates back to 1713, and the central temple-altar was erected almost a century later, as evidenced by the inscription on it. Over time, various chapels, caravanserais and cells grew up around the sanctuary, on which there are inscriptions made in Indian fonts.