According to ancient history Kubera was the King of Lanka and when he came to know that Ravana was going to attack his kingdom he quietly left everything and left to start his own Kingdom elsewhere.Thus Ravana when he came to Lanka found immense wealth and even the " Puspaka Vimana " the Flowery Aeroplane which could fly on the thinking of it's owner any place any time.
His mother was once worshiping Lord Shiva's Linga made by her using sand on the beach,perhaps near her palace.Strong waves washed away the Linga she was worshiping.The loss of the Linga she was worshiping made her Cry.Ravana who was perhaps near by heard her cry and after knowing the reason promised her he would bring the Atma Linga worshiped by Lord Shiva himself.He then left to Kailash the home of Lord Shiva and had a second thought as to why he cannot take the entire Kailash.
His strength was more than a trillion elephants and he tried to lift the Kailash with his twenty hands.Kailash starting shaking and Shri.Parvathi asked Lord Shiva as to what was happening.Lord Shiva told her that one of her Devote was trying to play and he just pressed his toe on the place he was sitting and Kailash stood very firm.
Ravana's hands were caught under the great weight of Kailash and he could not take it out.
He did not bother but started praying to Lord Shiva in the tune most liked by him.
Lord Shiva who loves his devotees more than anything presented himself and removed his hands caught under Kailash and took away all the pain.
Sage Narada who is always present in any place that would become a problem knew that Ravana would ask for Atmalinga.Sage Narada who knows all knew that Lord Shiva would give his Atmalinga without a second thought and that Ravana thus would be more powerful than any God if he worshiped or poss ed it, he prayed before Goddess Saraswathi, the Goddess who is responsible for our learning,knowledge and memory to make Ravana to forget what he would ask Lord Shiva.The power of Goddess Saraswathi made Ravana forget what he wanted to ask Lord Shiva when Lord Shiva presented himself befor Ravana and asked him what he wanted,Ravana was confused and not remembering about his wish to get Atmalinga for his mother he asked Lord Shiva that he wanted to take Goddess Parvathi with him to his place.Lord Shiva told Goddess Parvathi to go with him.
Goddess Parvathi told Ravana that she will go with him on the condition that he will not get any bad thoughts on the way.Ravana agreed and they left for Lanka.
On the way to Lanka Goddess Parvathi felt tired and hungry and told Ravana that she would rest and he can get some thing to eat for her.
Ravana after making Goddess Parvathi to sit under the tree by name " Kadamba" and entered the forest in search of fruits to eat.Here he met the daughter of the King Mayasura a beauty he had never seen and immediately he fell in love with her due to the power of Lord Vishnu who made it possible as other wise Ravana would normally never forget his promise to Goddess Parvathi that he would not get his mind on such thoughts,which was his promise to her.
Ravana returned deeply disturbed by seeing the beauty of Mandodhari in the forest met Goddess Parvathi and gave her fruits. Goddess Parvathi seeing the face of Ravana wanted to know why he was so sad.
Ravana told Goddess Parvathi about Mandodhari and requested her to help him marry Mandodhari.Goddess Parvathi blessed him and said your wish will be true but you have broken your promise that you will not get such thoughts on our way to Lanka so I am going back to join my husband Lord Shiva and youcan return to Lanka.
Ravana begged Goddess Parvathi not to go and when she was not prepared to listen to him he threatened her and tried to take her forcibly.Immediately Goddess Parvathi showed her most brutal form which made Ravana shiver with fear and told her to join Lord Shiva.
Ravana was now coming to fight with Mayasura father of Mandodhari but Sage Naradha intervened and there was no fight and Ravana married Mandodhari.
Ravana returned to Lanka with Mandodhari.
Lanka meanwhile was praising Kubera and his famous city Alakapuri.Ravana felt humiliated and wanted to take revenge and loot Kubera's kingdom and started his preparations to go to war with Kubera.
Ravana's mother told him that Kubera was the best devote of Lord Shiva and it was on acount of Lord Shiva's blessings that Kubera could do what he had achived.She also told him that if he had only brought Atmalinga instead of Mandhodari and had worshiped Atmalinga he could have done better than Kubera.
The moment Ravana heard the word Atmalinga he remembered his previous venture and Lord Shiva's gift of Goddess Parvathi and decided to bring Atmalinga to Lanka and rushed towords Kailash.
At the foot of Kailash he started his meditation nonstop praying to Lord Shiva to give him the Atmalinga.Lord Shiva known for his generous gift of any sort to his devoted devotees prayers was pleased to grant him his Atmalinga and told him that those who worshiped it would get anything that they wished but when he is taking it to Lanka he should never place it on earth and if it was done it would firmly get rooted on earth and would never even return to Kailash,having said so Lord Shiva disapeared.
Sage Narada saw this gift of Lord Shiva to Ravana and he could imagine the problems that would come if Ravana worshiped it at Lanka.
Sage Narada went to Lord Vishnu and together they planed to see that Ravana would fail in his endevover to take Atmalinga to Lanka.
They went to Lord Shiva's son and explained and requested him to help them in their plan and told him to some how make the Atmalinga to be placed on the ground.
Ravana carying the Atmalinga went towords south his place Lanka and was crossing a serious of hills in the westren borders of Karavali at Vindya Mountain the place that had come from the bottom of the ocean.He was nearing the shores of Gokarna.Ganapathi saw him and he took up the form of a bramhin cowheard and was standing near the sea shore.Lord Vishnu made his Sudarshan Chakra so big and made it look like evening by covering Sun.
Ravana was a firm mediator of Sandyavandhana the evening time you pray Gayitri Mantra daily.He was not knowing how to do his Sandyavandhana as he needed both the hands to pray and he had Atmalinga wich he could ot keep anywhere.
He saw Ganapathi in the form of a Bramhin Boy and requested him to hold the Atmalinga so that he could do his Sandyavandhana.Ganapati agreed and holding the Atmalinga told him it was very heavy and if he found it was not possible for him to hold it he would call him three times and if he failed to take it before the third time he would call him he would place it on the ground.Ravana had no choice but trust him and gave the Atmalinga and went to do his prayers.Ganapathi was waiting till such time he could call him three times when it would not be possible for him to come.
Exactly at the expected time he called Ravana three times and as Ravana came running to take the Atmalinga the third call was over and Ganapathi placed it on the ground.
Ravana banged his powerful first on Ganapathi's head and Ganapathi's head had a big dent on top and his stomach went down to his knees.
Ravana used all his powers and tried hard to pull it from the ground but it had rooted very firmly on the earth.Ravana got furious and throw the four decorated objects on Atmalinga to East,West,North and South and shouted Oh Lord Shiva you are Mahabaleshwara and at that time Lord Vishnu removed his Sudarshanchakra and Sun was shining all the Devata's started laughing at Ravana.
Ravana felt disgraced his face crest fallen he went back to Lanka.
Lord Shiva came down to Gokarna saw the twisted shape of his Atmalinga and Ganapathi, all the Devatha's were present as also Goddess Parvathi.Lord Shiva told all those present that hence forth he should be worshiped only after his son Ganapathi's worship and all those who worship his Atmalinga at Gokarna would get their desires fulfilled and would have his blessings,also he would reside in Gokarna to see his Devotees for ever.Ravana came to Gokarna with his mother and worshiped Atmalinga with his complete devotion and surrendered at the Atmalinga.Lord Shiva presented himself to Ravana and told him not to get disheartened and that his Atmalinga had to be placed on earth for the benefit of his devotees and his attempt was only towards that and people will praise you for your effort and disappeared.
Thus Gokarna has become a famous place where you get your desires fulfilled and reach heaven after your life on earth.
Om Namashivaih,Om namashivaih,Om namashivaih.