According to the legend, it is believed that during the Treta Yug, Ravana in order to get invincible powers worshiped Lord Shiva in the Kailash. For that, to please the our Lord Shiva, he offered his ten heads in the havan kund. Influenced by this extra ordinary deed of the Ravana, the Lord Shivanot only restored his heads but also bestowed him with powers of invincibility and immortality. On attaining this incomparable boon, Ravana also requested the Lord Shiva to accompany him to Lanka. Shiva consented to the request of Ravana and converted himself into Shivling. The Lord Shiva asked him to carry the Shivling and told him that he should not place the Shivling down on the ground on his way. Ravana started moving south towards Lanka and reached Baijnath where he felt the need to answer the nature’s call. On seeing a shepherd,Ravana handed over the Shivling to him and went away to get himself relieved. On finding the Shivling very heavy, shepherd kept the ling on the ground and the Shivling got established there and the same is in the form of Ardhnarishwar (God in form of Half Male & Half Female).