The Jataka, Vol. II, tr. by W.H.D. Rouse, , at sacred-texts.com
"’Tis best that you should know," etc.--This tale the Master told at Jetavana, about a courtier of the king of Kosala. This man was very useful to the king, we are told, and did everything that had to be done. Because he was very useful, the king did him great honour. The others were jealous, and concocted a slander, and calumniated him. The king believed their saying, and without enquiring into his guilt, bound him in chains, though virtuous and innocent, and cast him into prison. There he dwelt all alone; but, by reason of his virtue, he had peace of mind, and with mind at peace he understood the conditions of existence, and attained the fruition of the First Path. By and bye the king found that he was guiltless, and broke his chains and gave him honour more than before. The man wished to pay his respects to the Master; and taking flowers and perfumes, he went to the monastery, and did reverence to the Buddha, and sat respectfully aside. The Master talked graciously with him. "We have heard that ill fortune befel you," said he. "Yes, sir, but I made my ill fortune into good; and as I sat in prison, I produced the fruition of the First Path." "Good friend," said the Master, "you are not the only one who has turned evil into good; for wise men in the olden time turned evil into good as you did." And he told an old-world tale.
Once on a time, when Brahmadatta was king of Benares, the Bodhisatta was born as the son of his Queen Consort. He grew up and was educated at Takkasilā; and on his father's death he became king, and kept the ten royal rules: he gave alms, practised virtue,  and observed the sacred day.
Now one of his courtiers intrigued among the king's wives. The servants noticed it, and told the king that so and so was carrying on an intrigue. The king found out the very truth of the matter, and sent for him. "Never show yourself before me again," said he, and banished him. The man went off to the court of a neighbouring king, and then all happened as described above in the Mahāsīlava Birth 1. Here too this king thrice tested him, and believing the word of the courtier came with a great army before Benares with intent to take it. When this was known to the chief warriors of the king of Benares, five hundred in number, they said to the king,
"Such and such a king has come here, wasting the country, with intent to take Benares--here, let us go and capture him!
"I want no kingdom that must be kept by doing harm," said the king. "Do nothing at all."
The marauding king surrounded the city. Again the courtiers approached the king, and said,
"My lord, be advised--let us capture him!"
"Nothing can be done," said the king. "Open the city gates." Then, surrounded by his court, he sate down in state upon the great dais.
The marauder entered the town, felling the men at the four gates and ascended the terrace. There he took prisoner the king with all his court, threw chains upon them and cast them into prison. The king, as he sat in prison, pitied the marauder, and an ecstasy of pity was stirred in him, By reason of this pity, the other king felt great torment in his body; he burnt all through as though with a twofold flame; and smitten with great pain, he asked what the matter was.
They replied, "You have cast a righteous king into prison, that is why this is come upon you."
He went and craved pardon of the Bodhisatta, and restored his kingdom, saying, "Your kingdom be your own.  Henceforward leave your enemies for me to deal with." He punished the evil counsellor, and returned to his own city.
The Bodhisatta sat in state upon his high dais, in festal array, with his court around him; and addressing them repeated the first two stanzas:
"Therefore to all the world I bid you show
The grace of kindliness and friendship dear;
And then alone to heaven you shall not go.
O people of the Kāsi country, hear!"
Thus the great Being praised virtue in the way of pitying the great multitude; and leaving the white umbrella in the great city of Benares, twelve leagues in extent, retired to Himalaya, and embraced the religious life.
 The Master, in his perfect wisdom, repeated the third stanza:
When the Master had ended this discourse, he identified the Birth: "At that time Ānanda was the marauding king, but the king of Benares was I myself."
273:1 No. 51 (vol. i. p. 129 of this translation).