Lord Shiva as Kalantaka
Once there was a little boy named Markandeya. His father Mrikandu had to select one of two predetermined fates for him before he was born. The first one was that Markandeya would be a bright, knowledgeable young boy who would live till the age of 16. The second option was that he would live a long life but as a dull, foolish boy. Mrikandu chose the first fate for his son.
Thus Markandeya was destined to die before he was even born. As a child, he was quite intelligent and noble. Markandeya was also a great devotee of Lord Shiva and worshipped the Shivalingam at his home every day.
He continued worshipping Lord Shiva, even till the predetermined day of his death. Such was his unflustered devotion to Lord Shiva.
As the moment of his death approached, Lord Yama (the God of death) sent his messengers (Yamduts) to snatch the life from Markandeya’s body. When they arrived he was still praying to Lord Shiva. The messengers failed to take away his life, as his dedicated worship continued.
This is because Markandeya had learnt the Mahamrityunjay Mantra in the recent past. He was instructed to do this by Lord Brahma, who was aware of Markandeya’s fate. This mantra of Lord Shiva is especially powerful and it even has the power to defy death.