The sacred city of Puri and Jagannath Temple have found mentioned in various Hindu scriptures and canonical texts such as Skanda Purana, Brahma Purana, as well as Narada Purana. There is even a mention of the Lord Jagannath in Rig Vedas.
According to the legends, Lord Jagannath was originally worshipped as Lord Neela Madhaba by a tribal chief named Viswavasu secretly in the dense forest. When the King Indradyumna learned about this, he sent his high priest Vidyapati in search for the deity. When all his efforts to locate the deity failed, he married Viswavasu’s daughter and requested his father-in-law to show him the place of worship. Viswavasu obliged and took him blindfolded to a seclude cave in the midst of a forest where he used to worship.
The wise Viswavasu dropped mustard seeds on his way to the cave which germinated and helped him find the cave later on. On hearing from him, the King rushed to the cave to witness and worship the deity but the deity has disappeared. The disappointed king built a magnificent temple on the shore and fasted until death. In his sleep, he has a vision of Lord Jagannath who advised him to follow the fragrance of a tree on the shore and make wooden idols out if it.
Accordingly, the king got the image of Lord Jagannath, Balabhadra, Subhadra and Chakra Sudarshan made out of the wood of the divine tree with the help of Vishwakarma and installed them in the temple.