The story goes back to the times when the demon king Ravana had performed a tough meditation to please Lord Shiva. When after meditating for years, he could not please Lord Shiva, he did not lose hope and thought of another way to please the deity.
As a sacrifice, he started chopping off each of his heads and giving it as an offering. When he had cut nine of his heads and was about to chop off the tenth one, Lord Shiva appeared before him.
Lord Shiva said that since he was pleased with his devotion, he would fulfil one of his wishes. As a wish, Ravana asked Lord Shiva to accompany him to his kingdom, Lanka. Lord Shiva then agreed to his wish. As his symbol, he gave two Shivlingas to Ravana. While giving the Shivlingas to him, Lord Shiva said to him that wherever he keeps the Shivlingas, they will get established there. Lord Shiva just said that he should not keep them on the ground until he reaches the destination.
With all the blessings of Lord Shiva and all the rules in his mind, Ravana proceeded towards Lanka, his kingdom. It was a long distance from Kailash Parvat to Lanka. While on his journey, Ravana felt thirsty. As it would require him to keep the Shivlingas somewhere, in order to drink water, he decided to control the thirst for some time.
On the way, he saw a herdsman with his herd, who had brought his cattle to graze. Ravana thought that he should stop there and drink water with the help of the herds. Ravana stopped there and upon enquiring, he came to know that the place was known as Baijnath and the name of the person was Baiju. Ravana requested Baiju to hold the two Shivlingas for some time while he went to drink water.
Baiju agreed to help. He took both the Shivlingas from Ravana and sat under a tree, waiting for Ravana, while his cattle were grazing. However, since there was a lot of energy radiating from the Shivlingas, no ordinary man could keep them holding for long. The same happened with Baiju. He kept the Shivlingas on the ground when he could no longer hold them.
With this, the Shivlingas were established in Baijnath and the place came to be known as a holy place dedicated to Lord Shiva. As a result, Ravana had to return empty handed, but a temple was constructed around the area. While one Shivlinga is known as Chandra Maal, the other is known as Baijnath.