In Shiva Maha Purana, Shathrudra Samhita chapter, it explained about how Agneshwara Linga came into existence.
Vishwanar Does Penance for birth of Son
Once upon a time, there used to live a brahmin named Vishwanar who was a great devotee of lord Shiva. Shuchismati was his wife who was a devout wife. Being pleased by her sense of dutifulness, Vishwanar tried to reward his wife. Shuchismati expressed her desire of having a son just like lord Shiva. Vishwanar went to Kashi to please Lord Shiva by his penance. He worshiped Vishveshwar linga with supreme devotion. Lord Shiva became very pleased by his devotion and he appeared before Vishwanar from the Shivalinga. When Vishwanar expressed his desire, lord Shiva agreed to take birth as his Son. Vishwanar came back to his house happily.
Shiva’s Incarnation as Grihapati
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 Grihapati 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.
Grihapati then consoled his parents and proceeded towards Kashi to do penance so that the ‘death’ could be conqured.
Grihapati’s Penance and Agnishwar Lingam existance
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. Grihapati was very terrified. Right then Lord Shiva appeared and Indra had to retreat from the scene. Lord Shiva blessed Grihapati by saying – “What to say about this lightning – Vajra, even Kaalvajra would not be able to kill you.” Grihapati 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.