The above Shloka has been taken from the ‘Skanda Purana’ where lord Shiva is saying that if a person leaves his home and goes to the Kaal Bhairav Temple, every step he takes in reaching the temple will yield more Punya than performing Ashwa Medh Yagya.
Once there was a confrontation between Lord Vishnu and Lord Brahma as to who is superior to them. At the same time, Lord Shiva appeared in the form of a divine pillar which was Lighted up both in the downward direction and also in the upward direction.
Lord Shiva asked both Lord Brahma and Lord Vishnu that the one who finds an end to this divine light will be declared the most Supreme.
Lord Vishnu sat on a ‘Varaha’ (wild boar) and went downwards where as Lord Brahma sat on a ‘Swan’ and went upwards. Both of them tried very hard but could not find an end to the divine light after which they returned back to Lord Shiva.
Lord Vishnu accepted that he could not find an end to the lighted pillar whereas Lord Brahma who was one of the heads used to tell lies told that he did to find an end and hence he should be declared superior.
Hearing the lie from Lord Brahma, Lord Shiva got very angry and he took the Rudra Avatar (fierce form) of Lord Kaal Bhairav. And only with one of his fingers Lord Kaal Bhairav took off the head of Lord Brahma.
As a result, the head of Lord Brahma got stuck in the hands of Kaal Bhairav and he attained the ‘Brahma Hatya Dosha‘. Lord Kaal Bhairav went to many places but could not get rid of the Brahma Hatya Dosha.
When lord Kaal Bhairav went to ‘Vaikunth Dham‘ bhagwan Vishnu guided him to go to Kashi to get rid of the Brahma Hatya Dosha. When Lord Kaal Bhairav entered Kashi the head which was stuck in his finger fell down on the ground and he got freed from the Brahma Hatya dosha.
The place where the head of Lord Brahma fell was known as the ‘Kapal Mochan Teerth‘. From that day Lord Kashi Vishwanath appointed Kaal Bhairav as the guardian of the city of Kashi. And gave a blessing that all the devotees who will worship Lord Kaal Bhairav in Kashi all their wishes will be fulfilled and they will attain Shiva Bhakti.