After the Mahābhārata battle, Barbarika’s last wish was to see the war “Mahabharat” so Lord krishna himself placed his head on the top of a mountain for Barbarika to see the war. After many years when Kalyug started the head was found buried in the village of Khatu (District- Sikar) in present-day Rajasthan. The location was obscured until well after the Kaliyuga period began. Then, on one occasion, milk started flowing spontaneously out of a cow’s udder when she neared the burial spot. Amazed at this incident, the local villagers dug the place up and the buried head was revealed. The head was handed over to a Brahmin who worshipped it for many days, awaiting divine revelations as to what was to be done next. Roopsingh Chauhan, king of Khatu, then had a dream where he was inspired to build a temple and install the head therein. Subsequently, a temple was built and the idol was installed on the 11th day of the Shukla Paksha (bright half) of the month of Phagun.
There is another, only slightly different version of this legend. Roopsingh Chauhan was the ruler of Khatu. His wife, Narmada Kanwar, once had a dream in which the deity instructed her to take his image out of the earth. The indicated place (now known as Shyam Kund) when then dug up. Sure enough, it yielded the idol, which was duly enshrined in the temple.
The original temple was built in 1027 AD by Roopsingh Chauhan, after his wife Narmada Kanwar, saw dream about the buried idol. The place where the idol was dug out from is called Shyam Kund. In 1720 AD, a nobleman known as Diwan Abhaisingh renovated the old temple, at the behest of the then ruler of Marwar. The temple took its present shape at this time and the idol was enshrined in the sanctum sanctorum. The idol is made of rare stone. Khatushyam is the family deity of a large number of families.
His another temple is located at Vasna, Ahmedabad, Gujarat where people are coming with their newly born child to have blessings of Khatushyam. Here he is known as Baliya Dev.