The temple was built by King Kavan Tissa in the 2nd-century and dedicated to his wife Queen Viharamahadevi. The temple is built on a rocky hilltop overlooking the Indian Ocean, offering amazing views of the ocean from the top.
According to folklore, King Kelani Tissa who ruled Kelaniya of Sri Lanka punished an innocent monk by boiling him alive in an oil cauldron. The gods were annoyed by this sinful deed and made the ocean rush inland and flood the lands, probably a tsunami. In order to prevent this the king was advised to sacrifice his youngest daughter Viharamaha Devi to the sea. The young princess sacrificed herself for the sins committed by her father and to save the country. The princess was believed to reach ashore at Kirinda where the temple is located. The princess was brought before King Kavan Tissa the king of Rohana or Ruhuna area during the time. After hearing her story King Kavan Tissa decided to marry her. Later King Kavantissa built this temple and named it after Viharamaha Devi. She was the mother of Dutugemunu and Saddathissa who ruled Sri Lanka, Dutugemunu was one of the greatest heroes in Sri Lanka, and Saddathissa was the father of another great king Vatta Gamini Abhaya or Valagambahu.