Vishwanar was a sage who did not have a child. His wife Shuchismati wanted a child and he did penance to Lord Shiva for the same. In due course of time, Shuchismati became pregnant and gave birth to a beautiful child. The whole family celebrated the birth of the child. The whole family celebrated the birth of the child. The name giving ceremony of that child was attended by all the deities and sages including lord Shiva and Parvati. Lord Brahma named the child as Grihapati. When Grihapati attained the age of five, his sacred thread ceremony was performed. Within a year he became proficient in all the Vedas and other sacred texts.
When he attained the age of nine, Narada came and informed Vishwanar that death of Grihapati was imminent because of the evil effects of the planetary combinations. Vishwanar and Shuchismati were saddened and started crying.
He then consoled his parents and proceeded towards Kashi to do penance so that the 'death' could be conqured. Grihapati commenced his penance at Kashi. The deity Indra arrived there and requested him to demand anything he wished but Grihapati refused. Indra became furious and tried to attack him with his weapon-Vajra.
Right then Lord Shiva appeared and Indra had to retreat from the scene. Lord Shiva blessed him by saying - "What to say about this lightning - Vajra, even Kalvajra would not be able to kill you."
He became very pleased. The Shivalinga which he worshipped, later on became famous as 'Agnishwar linga. Lord Shiva made Grihapati the lord of all the directions.