In Shiva Mahapuranam, Rudra Samhita chapter explains about how Krittivaseshwar Shivalingam came into existence.
Gajasur’s revenge for killing his father Mahishasur
Gajasur was the son of Mahishasur. To avenge his father’s death, Gajasur did a tremendous penance to please lord Brahma. Lord Brahma appeared before him and asked him to demand any boon. Gajasur said- “O Lord! Even a ‘Jeetendriya’ (one who has full control over his senses) should not be able to kill me,” Lord Brahma blessed him by saying ‘So be it’. Gradually, Gajasur atrocities crossed all limits.
Gajasur Death Spot becomes Krittivaseshwar Linga
He became the lord of all the three worlds. He forced even the deities to worship him. He used to torment the brahmins and the other religious people. One day Gajasur arrived at Kashi and started tormenting the people living over there. The deities came to lord Shiva and requested him to rescue Kashi by killing Gajasur. Lord Shiva came to Kashi and fought a battle with Gajasur. He killed Gajasur with this trident. At the time of his death, Gajasur eulogized Lord Shiva and requested him to put his (Gajasur’s) skin on his (Shiva’s) body. Lord Shiva agreed to fulfill his wish. At the spot where, Gajasur was killed a famous Shivalinga by the name of Krittivaseshwar was constructed as per the own wish of lord Shiva.