The temple dates back to the ninth century when Kundavarman, the most famous king of the Alupa dynasty, was ruling Tulu Nadu. During this period, there were two holy saints of the Nath cult, Machindranath and Gorakhnath, who came from Nepal. They reached Mangalore, crossing the river Nethravathi. The place where they crossed the river came to be known as Gorakdandi. They chose a place near the banks of the Netravathi which was once the centre of activities of the sage Kapila. The ruling king met the two saints. Pleased with the humility and virtues of the king, they informed him that his kingdom needed to be sanctified with a temple for Mangaladevi. From their own mother he heard the story of Vihasini and Andasura, Parashurama and the temple built by them. The two saints took the king to the sites where all these historical events had taken place. They asked the king to dig the place and relieve the lingam and the dharapatra symbolising Mangaladevi and install them in a shrine along with Nagaraja for providing protection. Kundavarman built grand shrine to Mangaladevi was built on the hallowed place with the guidance of the sages. Even today the two temples of Mangaladevi and Kadri, Mangalore have maintained their connection. The hermits of Kadri Yogirajmutt visit Mangaladevi temple on the first days of Kadri temple festival and offer prayer and silk clothes.