According to mythology, Markandeya Rishi was the son of sage Markandu. Markandeya Rishi was a great devotee of Shiva and with the winning spells of Mahmritunjaya he had beaten the God of Death Yamraj too. He proved that by chanting Mahmritunjaya how one can even avoid death. He is is also one of the 8 immortal characters.

According to mythological context, when Markandu sage for a long time did not have a  child, he alsong with his wife started doing Shiva Tapasya. Shiva appeared before them and asked them whether they what a talented 16-year-old son or a son without any quality but with longest life? Markandu asked for the talented 16-year-old son.
This 16-year-old son later became Chiranjeevi Sage Markandeya. He decided to conquer death by Shiva’s devotion. Impressed with his devotion Brahmadev provided him with the knowledge of Mahamrityunjaya mantra.
Because of chanting this mantra regularly, when Yamraj came to take life of Markandeya on his decided date, the power of this mantra of Shiva failed Yamraj’s power of killing. He then became immortal.