The Jataka, Vol. II, tr. by W.H.D. Rouse, , at sacred-texts.com
"A happy lake," etc.--This story the Master told while dwelling at Jetavana, about the king of Kosala.
We are told that a certain courtier intrigued in the royal harem. The king inquired into the matter, and when he found it all out exactly he determined to tell the Master. So he came to Jetavana, and saluted the Master; told him how a courtier had intrigued, and asked what he was to do. The Master asked him whether he found the courtier useful to him, and whether he loved his wife. "Yes," was the reply, "the man is very useful; he is the mainstay of my court; and I do love the woman." "Sire," replied the Master, "when servants are useful, and women are dear, there is no harming them. In olden days too kings listened to the words of the wise, and were indifferent to such things." And he told an old-world tale.
Once upon a time, when Brahmadatta was king of Benares, the Bodhisatta was born into a courtier's family. When he came of age, he became the king's counsellor in things temporal and spiritual.
Now one of the king's court intrigued m the harem, and the king learnt all about it. "He is a most useful servant," thought he, "and the woman is dear to me. I cannot destroy these two.  I will put a question to some wise man of my court; and if I must put up with it, put up with it I will; if not, then I will not."
He sent for the Bodhisatta, and bade him be seated. "Wise sir," said he, "I have a question to ask you."
"Ask it, O king! I will make answer," replied the other. Then the king asked his question in the words of the first couplet:--
"Surely," thought the Bodhisatta, "one of his courtiers must have intrigued in the harem "; and he recited the second couplet:--
 Thus did the Great Being advise the king.
And the king abode by this advice, and he forgave them both, bidding them go and sin no more. And from that time they ceased. And the king gave alms, and did good, till at his life's end he went to fill the hosts of heaven.
And the king of Kosala also, after hearing this discourse, forgave both these people and remained indifferent.
When the Master had ended this discourse, he identified the Birth:--"At that time Ānanda was the king, and I myself was the wise councillor."