There was once a sage named Mrikandu and he had a wife called Marudvati. But they did not have any children. So, Mrikandu did penance to Lord Shiva to obtain children. Lord Shiva was pleased with him and asked whether he would like to have 100 foolish children who will live long or 1 intelligent child who would live for 16 years. Mrikandu chose the second option and Lord Shiva was happy. With Lord Shiva’s blessing, a boy was born and he was named Markandeya.
Markandeya grew up to be an intelligent boy who looked handsome as well. He learnt the Vedas and Scriptures quickly due to his intelligence and was liked by everyone around him. He was fast approaching the age of sixteen and Mrikandu became sadder by the day. When Markendaya approached his father about this, Mrikandu told him the sad truth. Markandeya then consoled him saying why he should worry when Lord Shiva was there. Saying so, Markandeya built a Shiva linga near the sea shore and started to worship it. He sang prayers and danced in delight around it.
The last day of his life came and soon Lord Yama (God of death) arrived there. He told the boy to leave the linga and come with him. Markandeya refused and clung to the linga. Yama got irritated and started to pull him away along with the linga. Out of the blue, Lord Shiva manifested from the Linga and kicked Yama on the chest. He told Yama to go away and not touch the boy. Yama went away disappointed. Markandeya was happy and he started to worship Lord Shiva more religiously than before. He then returned home to his parents who were overjoyed. He then lived and went on to become one of the greatest sages ever.