The story of Kāmākhyā starts from a very ancient time when Narakasura, who was the son of Varaha Avatara of Viṣṇu and Bhoodevi, battled the daitya-s who lived in Kamrupa and took over this land. He was then instructed by Varaha on the methods of worshipping Mahamaya and thus the Shaktipitha of Kāmākhyā came into being. It is said the Goddess had instructed Naraka not to allow anyone to enter the temple during the Brahmamuhurta and so Naraka would stand guard at the entrance of the hill. One day Rishi Vasistha came to this place to worship and realize Mahamaya, as instructed by his father Lord Brahma. As he approached the Nilachal mountain, Naraka stopped him from going further. Vasistha revealed his identity as a Rishi, yet Naraka would not budge. Angered, as Rishis would be in our shastras, Vasistha uttered a curse that this place of Mahāmāya would vanish from earth. The gods and other celestial beings who are said to inhabit the Nilachala mountain panicked, they approached Shiva for help. Shiva in turn used his own spiritual power and modified the curse, saying that for 300 years this place will be lost, and then again Kāmākhyā will reign as a glorious Shaktipitha. Naraka ruled over Kāmākhyā for a great length of time until he became adharmika and was finally destroyed by Sri Krishna.
During the medieval era the the king of Koch dynasty, Chilarai, it is said, lost his kingdom and was running away from enemies when he took shelter in the forest on the Nilaparvat. There he found an old lady sitting under a tree, who told him that he will regain his past glory if he were to sacrifice a goat at a specific spot which was revered by local tribes. The king did so and in a few months his enemies perished and he regained his kingdom. Then he collected a great group of scholars and pundits and ventured into the forests again and started digging that specific spot. Eventually old ruins of a temple emerged. The scholars after much deliberation unanimously declared that this is the famous pitha of Kāmākhyā which had been lost due to the curse of Vasistha. Chilarai and his son Naranarayan then rebuilt the temple placing a gold coin between every brick, as an act of gratitude to the Goddess.
Tantrik tenets were followed in this temple by both Hindu Śākta-s and Bauddha-s. Many of the great masters of Tibetan Buddhism, Naths and Sahajiya-s were from Kamrupa region, and practiced their sadhana around this temple. Even Swami Vivekananda had spent few months on the Nilachal mountain meditating on the Goddess when he started his life as an unknown pārivrājaka sadhu.
Devi Kāmākhyā is that form of Shakti which rules over all and is the source of all kinds of desires, small and big, dharmik and adharmik, everything. An old Śākta belief is that the Goddess acts like a mirror to each entity, human, asuric or divine, and shows them what their deepest, driving desire is – for we are but what our desires make of us. That indeed is the greatest magic of Mahāmāya Kāmākhyā. Everyone can know Mahāmāya, but only an aspect, as conditioned by his/her own propensity and desire, never the whole.