There are two legends. According to the first legend, 'Balakhilyas', a group of dwarf sages were praying to Lord Shiva for a long time. To test them, Lord Shiva appeared before them.
On seeing the Lord, the wives of the sages got attracted to the Lord and leaving their husbands behind they went after Lord Shiva. The sages got angry and cursed the Lord to lose his linga. Lord Shiva’s linga fell on the earth, shaking the whole earth. Lord Vishnu and Lord Brahma, requested Lord Shiva to save the earth. Lord Shiva listened to them and took back his linga and also promised his divine presence in Nageshwar 'jyothirlinga' for ever.
As per the other legend, there was a demon couple by the name Daruk and Daruka after whom was named Daruka Van, the forest which came to known as Dwarka. Daruk used to harass the local people. Once he captured a devotee of Lord Shiva named Supriya who was travelling on a boat.
He imprisoned her along with several other pilgrims in his capital Darukavana. Supriya directed the pilgrims to recite ‘Aum Namaha Shivayay’ to protect them. On coming to know of this Daruk ran to kill Supriya. At that very minute, Lord Shiva appeared in the form of a jyothirlinga from the earth to protect Supriya and her companions. Thus the lingam is so very revered.