This article does not cite any sources. (December 2009) (Learn how and when to remove this template message)
But one day, while he was out in the fields collecting flowers for worshipping the Lord, he happened to see a drunken sudra and a prostitute engaged in sexual embrace. Ajamila became bewildered and attracted; his mind becoming more and more attached to the prostitute. In Bhagavad-Gita it is said that if one contemplates sense objects, he becomes attached to them. Although Ajamila was a strict Brahmin he became helplessly entangled by seeing a man and woman engaged in sexual activity. Consequently he took this prostitute into his home as a maidservant. Inevitably, he became so entangled that he abandoned his family, wife and children and went off with the prostitute. Due to his illicit connection with the prostitute, he lost all his good qualities. He became a thief, a liar, a drunkard, even a murderer. He completely forgot about his original training as a Brahmin, and his whole life was ruined.
Engaging in sinful activities, Ajamila fell down from his position, and he begot many children through the prostitute. Even towards the end of his life, around the age of eighty, he was still begetting children. It is explained that while he was dying, which is a very fearful time, he began to call out to his pet child, whose name was Narayana. Narayana is another name of God or Krishna. At that time, the Yamadutas, the messengers of death, were coming. They were tying up the subtle body of Ajamila and preparing to take him to be punished by Yamaraja, the lord of death. At the same time, because he happened to be speaking the holy name of the Lord Narayana, the beautiful Visnudutas, the messengers of Krishna, also arrived there. They checked the activities of the Yamadutas, refusing to allow them to take Ajamila for punishment. The Yamadutas were bewildered. "Why are these effulgent and beautiful personalities checking our action? It's our duty to take sinful men to Yamaraja for punishment; then they are awarded another material body for the next life so that they can get the result of their sinful activity." There was a discussion between the Yamadutas and the Visnudutas. The conclusion was that although Ajamila was sinful throughout his life and gave up his religious life, his wife and children and begot children through a prostitute, he nevertheless was purified from all these sins because at the last moment he chanted the holy name of Krishna, Narayana. If this single act of the utterance of a four-syllable word Narayana can make such a difference to life after death, what larger worlds of fullness and majesty he may not conquer by really leading a noble life of Dharma in the memory of the Lord? -- so thought Ajamila. And that very moment he renounced everything to which he was attached, went to Haridv?ra and engaged himself in austerities and meditation and in due time reached the abode of the Lord.
It is noteworthy that a wrongdoer is given a chance to correct himself and thereafter lead a virtuous life before attaining salvation. It is not as if the Lord gives him a boon because he uttered the Lord's name when death was nearing him. It was the resultant of his previous good deeds that helped him to remember who he was and then get back to his previous position. Yet he had to struggle again and do enough penance before he could get salvation.