According to Shiv Purana, a Shiva devotee Supriya was attacked by the demon named Daaruka while travelling on a boat. The demon imprisoned him along with several others at his capital Daarukaavana where he resided with his wife Daaruki. Supriya advised every prisoner to chant the mantra 'Aum Namaha Shivaya'. When Daruk came to know about this recitation, furiously, he ran to kill Supriya. But, at that very moment Lord Shiva appeared in the form of a Jyotirlingam, vanquishing the demon with the Pashupata Ashtram. This Jyotirlingam manifestation of Shiva is worshipped as Nageshwara. According to Shiv Purana, whosoever praises with devotion the birth and greatness of this Jyotirlinga, shall beget all material happiness and divine status at the end.
The Nageshwar Mahadev Shivalingam faces south while the Gomugam faces east in the temple construction. Here is also a story behind such positional preferences. A devotee Naamdev was singing bhajans in praise of the Lord, when others asked him to step aside, as he was obstructing the view. To this Naamdev asked them to suggest a direction where the Lord was not present, so he could stand there. The infuriated devotees carried him to the south and left him there. But, to their bewilderment they found that the lingam was now facing south with the Gomugam to the east.