In the city of Kanya-kubja (today's Kanauj) there lived a brahmin by name Ajamila . Well trained in the vedic rituals, he lead a pious life, worshipping Lord Vishnu. Once, when he was collecting material in the forest for the sacrificial fire, he happens to see a drunk couple indulging themselves in mirth. Ajamila loses all sense of reason accrued by his learning and wavers from his duty.
He forsakes his aged parents and abandons his young wife too. He begins living with an unchaste wench. He spends all his money on her. After his father's fortune was thus exhausted, he gets money by foul means. He takes to gambling and liquor and also kills animals to feed his family of ten sons. He names his youngest son, his pet one, as Narayana. Engrossed in this kind of life, he does not perceive that death was approaching him. He was eighty eight years of age.
At the time of death, Ajamila beholds three terrifying figures with noose in hand about to drag him away. He calls out to his son “Narayana” -- in a loud and long tone, wanting to see his child who was at a distance, busy with his playthings.
Hearing the utterance of their Lord's name, the attendants of Lord Vishnu rushed to the spot. They forcibly stop the messengers of Yama, who were tearing away Ajamila’s soul with a noose to take him away.
Yama dhootas ask why they are being forbidden from doing their duty.
In a deep voice like the rumbling of clouds, Vishnu’s men laughed. “If you are truly Yama’s men, tell us the true character of virtue. Do you punish all those who commit sins?”
Yama's men recount Ajamila's wayward life and detail the consequences of the sins committed by him. As he has not atoned for it, he will be dragged to Yama’s court, where he will be purified through punishment.
In an ensuing debate, the Vishnudhootas expound the cult of devotion to the Lord and reason with
them -- “Whatever sins he may have committed, they have been wiped out by the fact that he pronounced the name of 'Narayana' at the time of death, even if he uttered it to denote someone else. Just
as medicine acts even if we do not believe in its efficacy.” They succeed in securing the release of Ajamila from the grip of death. He is given a chance to redeem himself.
The Yama dhootas go back and report the events to their Lord, Yama.
Ajamila, rid of his fear, regained consciousness of his earlier pious self, by a moment's association with the
Vishnu dhootas. He bows to them. As he begins to speak, they disappear.
Ajamila repents for his dissipation and the cruelty meted out to his wife and parents. He renounces everything and reaches Gangadvara (Haridvara) to meditate on Lord Vishnu. Withrawing his senses through yoga -- and his mind irrevocably fixed on Srihari, he beholds the Vishnudhootas again. He bows to them. Departing from his body and assuming a divine form, he enters the aerial car along with the Vishnudhootas, ascending to a realm of the divine, known as Vaikuntha.