Mylthology of Somnath Temple
The Skanda Purana, in a chapter on Prabhasa Khanda, describes Somnath. Legend has it that Shiva in the previous aeons was referred to as Mrityunjaya, Kaalagnirudra, Amritesa, Anamaya, Kritivasa and Bhairavanatha at Somnath.
Legend has it that the Kalabhairava Shivalinga (Bhairavanatha) at Prabhasa was worshipped by the moon, and hence Shiva here is referred to as Somnatha. The Skanda Purana describes the Sparsa Linga of Somnath as one bright as the sun, the size of an egg, lodged underground. The Mahabharata also refers to the Prabhasa Kshetra and the legend of the moon worshipping Shiva.
Legend goes that the moon was married to the 27 daughters of Daksha Prajapati. He was partial to Rohini, his favorite and neglected the others. An angered Daksha cursed him to wane into nothingness. A disturbed Chandra, came down to Prabhasa with Rohini and worshipped the Sparsa Linga of Somnath after which he was blessed by Shiva to grow and shine in the bright half. As the moon regained his light here, this town came to be known as Prabhasa. Bhrama, one of the trinity, installed the Bhramasila, and paved way for the construction of the temple.