At the end of Dwapar Yuga, Krishna realised that his end was near. He went to a forest and started meditating. When a huntersaw Krishna 's foot from behind some bushes, he thought that it was a deer and shot a poisonous arrow at it. Krishna died and was cremated.
Vishnu appeared in the dream of King Indradyumna and asked him to build a temple for Krishna's ashes. When he woke up, Indradyumna requested the divine artisan Vishvakarma to create an idol for the temple. Vishvakarma agreed on the condition that while he made the idol no one should disturb him. He locked himself up in a room and started work. After many days, when Vishvakarma did not come out, Indradyumna got impatient and broke down the door. Vishvakarma got angry and disappeared leaving the half finished idol of Jagganath behind him. Indradyumna had a beautiful temple built in Puri where the incomplete idol was placed.