Legend has it that in Krita Yuga (the first of the four yugas in Hindu tradition) all mountains in the world had wings and they could fly like birds. But people were sacred that they might fall down anytime and cause damage.
Saints and other beings approached Indra for a solution. As assembly of Devas was called and it was decided to clip the wings of the mountains.
Devas caught hold of the flying mountains and Indra then cut off the wings of all mountains with his weapon Vajra. But when he tried to cut the wings of Mainaka Mountain it moved away. Devas tried to hold the mountain down but could not as it was moved from the spot again by a strong wind.
Vayu Deva, the wind god, was a friend of Mainaka Mountain . He thwarted all attempts of Indra. Finally, Vayu agreed that Mainaka Mountain will not fly over land and cause damage. Vayu then deposited Mainaka Mountain in the ocean and asked him not to fly over earth.
As Hanuman was the son of Vayu, Mainaka Mountain rose up and gave a resting spot to Hanuman to show his gratitude to Vayu.