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. 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 completely forgot his values, and indulged in sinful life.
As a result, he had children with "then-prostitute" and in serving his woman and children, he neglected devoting time to the God. But, due to his past moral values and devotion to the God, Ajamila was capable of seeing Yamadutas - the servants of Lord Yama (one who is in charge of ending lives when they are supposed to be), when they arrived to take out his soul. He was so into his family, that even in his death bed, he called out to his son, whose name was Narayana, instead of praying to God. (Narayana is another name of Lord Krishna). Lord Krishna appeared at that instant and took Ajamila with him, cleansing him off his sins in his life. Although Ajamila didn't devote his life to prayer, he was purified from all his sins because at the last moment he chanted the holy name of Krishna, Narayana.
The story promises that the Lord is waiting for man to call for him. Even an innocent utterance of His name is enough for Him to lend helping hands to man.