The most famous of these stories is the one mentioned in Markandeya Purana. According to this legend, Harishchandra gave away his kingdom, sold his family and agreed to be a slave – all to fulfill a promise he had made to the sage Vishwamitra.

According to a legend mentioned in Aitareya Brahamana, Harishchandra had 100 wives, but no son. On advice of the sage Narada, he prayed to the deity Varuna for a son. Varuna granted the boon, in exchange for an assurance that Harishchandra would make a sacrifice to Varuna in the future. As a result of this boon, a son named Rohita (or Rohitaswa) was born to the king. After his birth, Varuna came to Harishchandra and demanded that the child be sacrificed to him. The king postponed the sacrifice multiple times citing various reasons, but finally agreed to it when Rohita became an adult. Rohita refused to be sacrificed and escaped to forest. An angry Varuna afflicted Harishchandra with a stomach illness. Rohita intermittently visited his father, but on advice of Indra, never agreed to the sacrifice. Later, Rohita managed to substitute himself with Sunahshepa in the human sacrifice. Sunahshepa prayed to the Rigvedic deities, and was saved from the sacrifice. Harishchandra's illness was also cured because of Sunahshepa's prayers; Sunahshepa was adopted by the sage Vishvamitra.[1]

King Harishchandra lived in the Treta Yuga. He was an honest, noble and just king. His subjects enjoyed prosperity and peace. He had a queen named Shaivya (also called Taramati) and a son named Rohitashva. Once, while on a hunting expedition, he heard the cries of a woman asking for help. Armed with a bow and arrow, he went in the direction of the sound. The sound was an illusion created by Vighnaraja, the lord of the obstacles. Vighnaraja was trying to disturb the tapasya (meditation) of the sage Vishwamitra. When he saw Harishchandra, he entered the king's body and started abusing Vishwamitra. This disturbed Vishwamitra's tapasya, and destroyed all the knowledge that the sage had acquired during this tapasya.

When Harishchandra came to his senses, he realized that the sage was extremely angry with him, and apologized. He promised to fulfill any of the sage's desires to get rid of his guilt. Vishwamitra demanded dakshina (donation) for his rajasuyayajna. The king asked him what he wanted in payment. In response, Vishwamitra said "Give me all that you have except yourself, your wife and your child." Harishchandra agreed to the demand. He let go of all his possessions – even his clothes. As he readied to leave his palace with his family, Vishwamitra demanded another donation. Harishchandra said that he did not have any possession left, but promised to make another donation within a month.

Harishchandra started living in penury with his wife and his family. His loyal subjects followed him. When Vishwamitra saw the king with his subjects, he started cursing Harishchandra for taking along his subjects (who were a part of the kingdom donated to the sage). The king then decided to leave the kingdom with his family. To make them go away sooner, Vishwamitra started beating the queen with a stick. When the five guardians of the directions saw this, they condemned Vishwamitra. The sage cursed them to take birth as human beings. These guardian deities were born as the sons of the Pandavas and Draupadi.

Nearly a month after leaving his kingdom, Harishchandra arrived in the holy city of Kashi, only to see Vishwamitra already present there. The sage demanded the donation that the king had promised him. Harishchandra pointed out that there was still some time left in completion of one month. The sage agreed to come back at the next sunset and departed. As his hungry son cried for food, Harishchandra worried how would he be able to make a donation to the sage. His wife Shaivya suggested that he sell her to get some money. After some hesitation, Harishchandra accepted the proposal and sold her to an elderly man. Their child would not let go of his mother, so it was decided that he would accompany his mother (and an extra payment was made for him).

Soon after, Vishwamitra appeared again and demanded the donation. Harishchandra gave him all the money he had received from the sale of his wife and son. However, Vishwamitra was unhappy with the donation, and demanded more. Harishchandra then decided to sell himself. An outcastechandala (actually the deity of dharma in disguise) offered to buy him, but Harishchandra's self-respect as a high-caste Kshatriya would not allow this. He instead offered to be Vishwamitra's slave. Vishwamitra agreed, but then declared "Since you are my slave, you must obey me. I sell you to this chandala in exchange of gold coins." The chandala paid the sage, and took along Harishchandra as a slave.

The chandala employed Harishchandra as a worker at his cremation ground. He directed Harishchandra to collect fees for every body cremated there: a part of the fee would go to the chandala, a part would be given to the local king, and the rest would be Harishchandra's remuneration. Harishchandra started living and working at the cremation ground. One day, he dreamed about his past lives, and realized that his current condition was a result of his past sins. During this nightmare, he also saw his queen crying before him. When he woke up, he saw his queen actually crying before him. She held the dead body of their son, who had died of a snake bite. Thinking of his misfortune, Harishchandra thought of committing suicide, but then realized that he would have to continue paying for his sins in his next life.

Meanwhile, the queen readied to cremate the dead body of their son. But, Harishchandra told her that he would not let her do so without paying the fee. At that time, all the deities appeared led by the deity of Dharma and accompanied by Vishwamitra. They praised Harishchandra for his good qualities, and invited him to heaven.

But Harishchandra refused to go to heaven without his public who have lamented over his departure from his kingdom. He believes that they are the equal sharer in his merits and that he will only go heaven when his people also accompany him. He requested the king of devas, Indra to allow his people to go to heaven at least for a single day. Indra accepts his request, and he along with his people ascend to the heaven.[7]

After his ascension to heaven, Vashistha – the sage of Harishchandra's royal dynasty – ended his tapasya of 12 years. He came to know about the unfortunate events that had happened to Harishchandra during these years. He started a severe fight with Vishwamitra, but was ultimately pacified by Brahma. Brahma explained to him that Vishwamitra was only testing the king, and had actually helped him ascend to the heaven.

This story affected Mahatma Gandhi, who was deeply influenced by the virtues of telling the truth when he watched the play of Harishchandra in his childhood.[8]

The Devi-Bhagavata Purana contains a story similar to the one mentioned in the Markandeya Purana, but also contains a reference to the Aitareya Brahamana legend. This legend is narrated by Vyasa to Janamejaya. It starts with Vashistha – the sage of Harishchandra's royal dynasty – praising the king's honesty and noble character. Vishwamitra objects to this, pointing out that Harishchandra was ready to sacrifice Sunahshepa, a human. He promises to prove that Harishchandra is not of noble character, and tricks the king into breaking his tapasya. The rest of the story is similar to the Markandeya Purana version, with minor variations.[9]

In Mahabharata, Narada tells Yudhishthira that Harishchandra is a rajarshi (king-sage), and the only earthly king who finds a place in the assembly of gods. According to Narada, Harishchandra was a powerful emperor, and all the kings on earth accepted his suzerainty. He performed the rajasuya yajna. After completing the rituals, he gratified the Brahmins with delicacies, gave them what they wanted and gifted them jewels. For this reason, he finds a place alongside Indra (the king of gods).[10]

Poet Raghavanka's Harishchandra Kavya from 12th century in Kannada language is a very popular and acclaimed epic on the life of Harishchandra.

Harishchandra has been the subject of many films in India. The earliest is Raja Harishchandra from 1913, written and directed by Dhundiraj Govind Phalke; it is the first full-length Indian feature film.,[11] The first "talkie" of Marathi cinema, Ayodhyecha Raja (1932) directed by V. Shantaram, was also based on his life, starring Govindrao Tembe and Durga Khote as the lead roles. The film was later remade under the name Ayodhya Ka Raja (1932) in Hindi, making it the first double-language talkie of Indian cinema.[12] The Kannada epic Satya Harishchandra was based on 12th century Hoysala poet Raghavanka's work, Harishchandra Kavya starring Dr Rajkumar. At the 13th National Film Awards, the film was awarded the President's silver medal for the Best Feature Film in Kannada. The film was hugely successful at the time of its release and is seen as a milestone in Kannada cinema. Satya Harishchandra was the third Indian and first South Indian film to be digitally coloured. The coloured version, released in April 2008, was a commercial success. Also in popular colloquial, Raja Harishchandra is synonymous with absolute adherence to truth. A person is often chided as being "a Raja Harishchandra", if he tries to cling to truth even to the detriment of those related to him. In 1985 a Bengali language film Harishchandra Shaibya was released based on the life of King Harishchandra. This film was directed by Ardhendu Chatterjee.