Mrikandu rishi and his wife Marudmati worshipped Shiva and sought from him the boon of begetting a son. As a result he was given the choice of either a gifted son, but with a short life on earth or a child of low intelligence but with a long life. Mrikandu rishi chose the former, and was blessed with Markandeya, an exemplary son, destined to die at the age of 16.
Markandeya grew up to be a great devotee of Shiva and on the day of his destined death he continued his worship of Shiva in his form of Shivalingam. The messengers of Yama, the god of death were unable to take away his life because of his great devotion and continual worship of Shiva. Yama then came himself in person to take Markandeya's life away and sprung his noose around the young sage's neck. By accident of fate the noose mistakenly landed around the Shivalingam, and out of it, Shiva emerged in all his fury attacking Yama for his act of aggression. After defeating Yama in battle to the point of death, Shiva then revived him, under the condition that the devout youth would live forever. For this act, Shiva was thereafter known also as Kaalakalaya, meaning 'one who brought death, to death himself'.