The Bodhisatta was once an ascetic who lived alone in the Himalayas, eating fruits and roots. One time he went down to a city to get salt and vinegar and he slept in the royal park. The next morning, the king saw the Bodhisatta out collecting alms and, impressed by his demeanor, invited him into the palace for a big meal. After they talked, the king invited the Bodhisatta to remain in the city and live permanently in his park. The Bodhisatta accepted the offer and stayed there, being fed and cared for by the king, for twelve years.
When the king needed to go put down an uprising in a border region, he told his queen to look after the Bodhisatta. One morning the Bodhisatta was late departing to the palace for his meal, so the queen took a bath and lay down on a small couch to dry off in the wind. Because he was late, the Bodhisatta flew through the air. And when the queen heard him arrive at her window, she hastily rose to greet him and her robe slipped off. The Bodhisatta saw her naked and was overcome by the sight: his heart filled with lust and his insight vanished. He took the queen’s hand and drew a curtain around them and they had sex. Then he ate and returned to his hut. The Bodhisatta continued to burn with lust and the two continued their misconduct day after day.
The affair became known around the city and the king’s advisors sent him a letter informing him what was going on in the palace. But the king respected the Bodhisatta so much he refused to believe it. Once the battle was won, the king returned and asked his queen about it, and she confessed. But the king still did not believe the Bodhisatta would do such a terrible thing and he went to ask him directly. The Bodhisatta knew that if he lied the king would believe him, but he would lose his path to Buddhahood—lying being much worse than fornication—so he confessed. The king respected his honesty and forgave him. Having recovered his power of concentration, the Bodhisatta gave a final sermon to the king and returned to the Himalayas where there were no women to tempt him.
In the Lifetime of the Buddha
One of the Buddha’s disciples began lusting for a woman he saw wearing beautiful clothes. He grew depressed and decided to leave the sangha. When the Buddha heard about his problem, he told the disciple that lust can cause a man to be born in hell and then told this story from his past so the disciple knew that he himself had also once succumbed to lust, but was able to overcome it. After that, the disciple decided to stay.
The king was an earlier birth of Ananda, one of the Buddha’s top disciples.