Harishchandra was son of Trishanku and king of Ayodhya, twenty-eighth in descent from Ikshvaku, the founder of the solar dynasty.

According to an Indian mythological story, in order to satisfy the claims of the sage Vishvamitra, who wanted to test his integrity, he parted with his kingdom and all that he had, sold his wife and only son and hired himself out as the employee of a pariah who kept a burning Ghat. Whenever a dead body was brought for cremation there, Harishchandra used to recover the toll and make it over to his master.

One day it so happened that a snake bit his only son, Rohit, and the ex-queen brought the dead prince for cremation to the same Ghat. Even though the ex-king recognized them to be his own wife and child, he would not allow the child to be burnt without recovering the usual toll. At last the penniless woman offered to part with the rag with which she had covered her shame and the heartless ex-monarch was going to strip her naked when the gods interposed and restored the pious king to his throne and all his former prosperity.