Yama is also the lord of justice and is sometimes referred to as Dharma, in reference to his unswerving dedication to maintaining order and adherence to harmony. It is said that he is also one of the wisest of the devas. In the Katha Upanishad, among the most famous Upanishads, Yama is portrayed as a teacher. He is the father of Yudhisthira, the oldest brother of the 5 Pandavas and is said to have incarnated as Vidura by some accounts in the Mahabharata period.
Yama, although a controller, is still subordinate to the ultimate controllers Shiva and Vishnu. A story of Yama`s subordinance to Shiva is well-illustrated in the story of Markandeya. Yama is called Kala ("time"), while Shiva is called Mahakala ("greater time").
Another incidence, which shows Yamas obedience to Vishnu, is as folows: A man Ajamila had committed many evil acts during his life such as stealing, abandoning his wife and children, and marrying a prostitute. At the moment of his death he involuntarily chanted the name of Narayana (the Sanskrit name for Vishnu) and achieved moksha, becoming saved from the messengers of Yama. Although Ajamila had actually been thinking the name of his youngest son, Narayana`s name has powerful effects, and thus Ajamila was released from his great sins.