This interesting story of Ravan and Shri Ganesh is found in the Ganesh Puran. Ravan was an asura and also the King of Lanka. He was an ardent devotee of Lord Shiva and had done severe penance for many years. Lord Shiva was very pleased with his devotion and appeared before him. Ravan asked Shiva to grant him a boon whereby Lanka would remain unaffected, even if the whole world gets washed away by a deluge at the end of the Yuga.
Shiva thought about it and gave him a ‘Shivling’. He asked Ravan to install it in his city which would protect him. However, there was one condition. Ravan would not carry the ‘Shivling’ in any vehicle and not put it down anywhere even by mistake. Ravan thanked Lord Shiva and carried the ‘Shivling’ with devotion.
Devraj Indra came to know about this boon and felt threatened by it. He sought the assistance of Shri Ganesh who promised to help. As Ravan was heading south, Shri Ganesh came in the guise of a young Brahmin boy in front of him. Just then Ravan, had the urge to go for a nature’s call. He said to the boy ‘Would you hold the shivlinga for some time? I need to take a break.’ The boy said ‘Alright. But please note, I need to get home by sunset. Also, I will call you thrice when the time is up. If you don’t return soon, I will put it down.’
Ravan agreed and hurried to step away. Time passed by and the sun was about to set. For some reason, the nature’s call extended and Ravan couldn’t come back in time. The boy called out thrice and at once put the ‘Shivlinga’ down. The ‘Shivlinga’ was installed at that very place. When Ravan returned he saw the ‘Shivlinga’ on the ground. He tried to lift it with his ten hands but failed.
An enraged Ravan hit the boy on his head. Then Shri Ganesh showed his real self and threw Ravan away with his trunk. Ravan realized his mistake and prayed to Shri Ganesh. The place where the ‘Shivlinga’ got installed was Gokarna and the Lord is – Mahabaleshwar Jyotirling. It was Shiva’s will to stay at Gokarna as Mahabaleshwar. This is why Shri Ganesh was sent there.