According to the stories narrated in the Shiva Purana, it was in the Treta yuga that the demon Ravana, king of Lanka, felt that his capital would not be perfect and free from enemies unless Mahadeva (Shiva) stays there forever. He paid continuous meditation to Mahadeva. Ultimately Shiva got pleased and permitted him to carry his Atmalinga with him to Lanka. Mahadeva advised him not to place or transfer this lingam to anyone. There should not be a break in his journey to Lanka. If he deposits the lingam anywhere on the earth, in the course of his journey, it would remain fixed at that place forever. Ravana was happy as he was taking his return journey to Lanka.

The other gods objected to this plan; if Shiva went to Lanka with Ravana, then Ravana would become invincible, and his evil and anti-vedic deeds would threaten the world.They never liked to see Lord Shiva as his protector. They devised a plan for outwitting Ravana. They requested Varuna (the god of water) to enter into the belly of Ravana, on his way back from Mount Kailash. So, on his way back, Ravana felt a severe urge to release water. He began looking for a man to whom he could temporarily entrust the lingam. Lord Ganapathi appeared before Ravana in the guise of a Brahmin. Unaware of the mystery, Ravana handed over the lingam to the Brahmin. Unfortunately, Ravana could not ease himself soon.
Meanwhile, the Brahmin placed the lingam at this place which was and which is now Baidyanathdham.
Ravana tried hard to remove the lingam from the spot where it had been placed. He could not turn out the lingam even an inch. This made him frustrated. He used violence but he only succeeded in pushing the lingam by thumb and damaging it. Later on he felt guilty of his doings and begged for forgiveness. The Gods were happy that the Shiva linga had not reached Ravana's place.
He returned to Lanka but visited daily to worship the lingam. This continued forever. The place where Ravana descended on the earth is identified with the present Harilajori about four miles north of Baidyanathdham. The place where the lingam was kept is now Deoghar and the lingam itself is known to all as Baidyanath Jyotirlingam.
According to other traditions, the 'LINGAM' (Lord Shiva) lay neglected after the death of Ravana until it was noticed by a rude hunter, Baiju, who accepted it as his God and worshiped it daily; proclaiming to the world, as the Lord of Baiju (Baidyanath).
Difficulty in identifying location of Baidyanath Jyotirlinga
Legend
Shravan Mela
Description of Temple