Several stories are associated with the establishment of the temple.
According to legends and also written in Veds and Purans, Goddess Sati burnt herself alive in Yagna, which distressed Lord Shiva. He picked the body of Sati on his shoulder and started his Tandava dance. This horrified all the deities in the heaven as this could lead to holocaust. This urged Lord Vishnu to unleash his Chakra that cut the Sati's body into 51 pieces. Shri Naina Devi Temple is the place where the eyes of Goddess Sati fell down.
Another story related to the temple is of a Gujjar boy. Once he was grazing his cattle and observed that a white cow is showering milk from her udders on a stone. He saw the same thing for next several days. One night while sleeping, he saw Goddess in his dreams who told him that the stone is her pindi. Naina told about the entire situation and his dream to Raja Bir Chand. When Raja saw it happening in reality, he built a temple on that spot and named the temple after Naina's name.
Shri Naina Devi Temple is also known as Mahishapeeth because of defeat of demon Mahishasur by the Goddess. According to the legends, Mahishasur was a powerful demon who was blessed with the boon of immortality by Lord Brahma, but the condition was that he could be defeated only by an unmarried woman. Due to this boon, Mahishasur started spreading terror on Earth and Gods. To cope with the demon, all Gods combined their powers and created a Devi to defeat him. The Devi was gifted different types of weapons by all Gods.
When Mahishasur got mesmerized by the immense beauty of Devi and proposed her to marry him. Devi told him that she would marry him if he would overpower her. During the battle, Devi defeated the demon and took out both his eyes. This urged Gods to happily applaud "Jai Naina" and hence the name.