Rishi Markandeya was a great devotee of Lord Shiva.
He was the son of Rishi Mrikandu and Marudmati , both of them were were the devotees of Lord Shiva. They worshiped Lord Shiva to bless them with a son. Lord Shiva gave them a choice of having a Knowledgeable son but with less life or to have less intelligent son with long life. Rishi Mrikandu chose to have a Knowledgeable son. Marudmati gave birth to a very intelligent son and they named him, Markandeya. Markandeya was some how aware of the fact that he is Alpa-Ayu (Alpa means less and Ayu means life) . He created a powerful Mantra which we call Maha Mrintujaya Mantra.
OM. Tryambakam yajamahe
Sugandhim pushti-vardhanam
Urvarukamiva bandhanan
Mrityor mukshiya mamritat
Click here to know its meaning
Because of the power of this Mantra ,the messangers of Yama , the god of death could not take away the life of Markandeya. Yama himself came to Markandeya to take away his life. Markandeya was chanting Mahamrintujaya Mantra , sitting in front of Shiva Linga . Yama sprung the Noose threw the window on Markandeya’s neck, but by fate of Markandeya or the mercy of Lord Shiva it landed across the Shiva Linga.
Shiva emerged out of the Shiva Ligna in his Rudra Roop (form of anger) and he defeated Yama, for the life of Markandeya.Yama begged forgiveness form Shiva and promised him to grant long life to Markandeya. Thus Shiva came to be Known as Kalantaka which means the ender of death.
Shiva blessed The Maha Mrintujaya Mantra as the mantra of Moksha (releasing from circle of life and death).