Once, after defeating Kubera, his step-brother, King Ravana was returning from Alakapuri to Lanka in a Pushpaka Vimana. On the way, he had to cross Mount Kailash where Lord Shiva and Parvati devi were enjoying their private moments. To his surprise, Ravana found that he couldn't cross the mount, and Nandi, Shiva's attendant, politely asked Ravana to change course.
Infuriated, Ravana decided to uproot the Kailash mountain. As he proceeded to lift it, Kailash began to shake, and a terrified Parvati embraced Shiva. However, the omniscient Shiva realized that Ravana was behind the menace and pressed the mountain into place with his big toe, trapping Ravana beneath it. Ravana gave a loud cry in pain. Since Ravana cried, he was given the name "Ravana" – one who cried. (parimaLa migavuLa)
Ravana's mother, a staunch devotee of Lord Shiva, was worshipping a Shiva Linga to bring prosperity to her son. Indra, the Lord of Heaven, who was jealous of this worship, stole the Shiva Linga and threw it away into the Sea. The distraught mother of Ravana went on a hunger strike as her devotional worship of Shiva was disrupted. Ravana then promised his mother that he would go to Mount Kailash, the abode of Lord Shiva, and bring the main Atmalinga itself for her worship.
Advised by his ministers Ravana is said to have sung hymns in praise of Shiva for a thousand years, aided by a stringed musical instrument created by cutting out his own body parts. It is believed that the hymns were the origin of the ‘Sama Gaanam’, which so pleased the Lord that He not only forgave Ravana but also gave him an 'Atma Lingam' that he could take to Lanka. There was one condition though. Ravana should not put the Lingam on the ground, and if he did, the Lingam would get rooted to the ground. Worried that the Lingam would make Ravana powerful, the Devas conspire and, avail the help of Ganesha. Ganesha appears before Ravana as a young boy and agrees to hold the Lingam till Ravana completed his morning Shiva Puja on the river bank. However, under the pretext that the Lingam is too heavy, the boy puts the Lingam on the ground after calling out Ravana thrice. Ravana tries unsuccessfully to pull out the Lingam, but the Lingam remains unshakable. In anger, Ravana knocks the head of the boy.
The place the event unfolds is Gokarna, and the Lingam is called 'Mahabaleshwara'. The deity, a carved stone image of Lord Shiva, is seen in a standing position with two arms. The Linga is partially enclosed in a holed square called ‘Saligrama Peetha’ where devotees can see and touch the top of the Atmalinga.
The temple also has a granite image of Sidda Ganapati; at the top of its head there is hole that is said to be a mark of a violent blow inflicted by Ravana.