One day, the devil Ravana undertook very difficult tapas .
As a consequence, Shiva appeared to him. Ravana requested a favor. He wanted that his kingdom and himself could never be damaged or destroyed. As a present, Shiva gave him a Shiva Lingam , the symbol of Shiva; he ordered to bring it back to his kingdom and to place it in a temple after adequate rituals.
After that, he would become unconquerable. But there was a prerequisite : whatever happened, he ought not to lay down the Lingam on the floor, under pain of not be able to displace it later.
Overjoyed, Ravana welcomed the Lingam. However, the Deva (Gods) felt afraid of the power that Ravana; could obtain. They invoked Ganesh before any action.
Then, Varuna , the god of Waters, penetrated into the Râvana's abdomen, causing him troubles which forced him to stop on his way. Râvana was convulsed with pain, but careful not to lay down the Lingam on the ground, as requested expressly by Shiva. Râvana called a young Brahman coming that way; he asked him to keep the stone Lingam just for a moment.
As soon as Râvana entrusted him the Lingam, the boy cried out for help three times. Getting no reply, he put the Lingam on the ground.
When Ravan came back, he was very angry and he dismissed the boy who just appeared to be Ganesh in reality. But Râvana had the power of the Lingam. Then Ganesh could easily subdue the devil, kicking to the sky.
Râvana realized his limitations and admitted the huge power of Ganesh.
The place where the Lingam was deposited is called Gokarna, and is located on the Karnataka western coast; it is a worshipping place till nowadays.
This story teaches that the demon is always defeated at the very end, specially when he thinks himself very powerful.