Legend is that a Rishi called Devala killed a snake by accident. His Guru cursed him; due to this Devala’s face looked like a Naga hood. Thus Devala came to be known as Nagarishi. His Guru directed Devala to worship Lord Shiva continuously so that his curse gets alleviated.
So, Nagarishi started worshipping Lord Shiva day and night. One day he received a Shiva Linga through his dreams (this Linga is believed to have worshipped, as Kiratha Murthy, by Arjuna of Mahabharata)
The rishi continued his worship of Lord Shiva; moving place to place carrying this Shiva Linga. One day, when he reached the present spot of the temple, the Shiva Linga got stuck there. He also had a feeling that he is getting relieved from his curse. Lord Shiva along with Parvati appeared and blessed him at this spot. Naga rishi requested the Lord to take abode there. The Lord agreed; took abode at the present temple in Gowri Sankara form.
The Shiva Linga believed to have worshipped in Kirata form can be seen at the Northern side of the temple, popularly known Kirathamoorthy shrine.
The temple is in the heart of Ernakulam city near the High Court of Kerala.