The Jataka, Volume I, tr. by Robert Chalmers, , at sacred-texts.com
 "The dogs that in the royal palace grow."--This story was told by the Master while at Jetavana, about acting for the good of kinsfolk, as will be related in the Twelfth Book in the Bhaddasāla-jātaka 2. It was to drive home that lesson that he told this story of the past.
Once on a time when Brahmadatta was reigning in Benares, the result of a past act of the Bodhisatta was that he came to life as a dog, and dwelt in a great cemetery at the head of several hundred dogs.
Now one day, the king set out for his pleasaunce in his chariot of state drawn by milk-white horses, and after amusing himself all the day in the grounds came back to the city after sunset. The carriage-harness
they left in the courtyard, still hitched on to the chariot. In the night it rained and the harness got wet. Moreover, the king's dogs came down from the upper chambers and gnawed the leather work and straps. Next day they told the king, saying, "Sire, dogs have got in through the mouth of the sewer and have gnawed the leather work and straps of your majesty's carriage." Enraged at the dogs, the king said, "Kill every dog you see." Then began a great slaughter of dogs; and the creatures, finding that they were being slain whenever they were seen, repaired to the cemetery to the Bodhisatta. "What is the meaning," asked he, "of your assembling in such numbers?" They said, "The king is so enraged at the report that the leather work and straps of his carriage have been gnawed by dogs within the royal precincts, that he has ordered all dogs to be killed. Dogs are being destroyed wholesale, and great peril has arisen."
Thought the Bodhisatta to himself, "No dogs from without can get into a place so closely watched; it must be the thoroughbred dogs inside the palace who have done it. At present nothing happens to the real culprits, while the guiltless are being put to death. What if I were to discover the culprits to the king and so save the lives of my kith and kin?" He comforted his kinsfolk by saying, "Have no fear; I will save you.  Only wait here till I see the king."
Then, guided by the thoughts of love, and calling to mind the Ten Perfections, he made his way alone and unattended into the city, commanding thus, "Let no hand be lifted to throw stick or stone at me." Accordingly, when he made his appearance, not a man grew angry at the sight of him.
The king meantime, after ordering the dogs' destruction, had taken his seat in the hall of justice. And straight to him ran the Bodhisatta, leaping under the king's throne. The king's servants tried to get him out; but his majesty stopped them. Taking heart a little, the Bodhisatta came forth from under the throne, and bowing to the king, said, "Is it you who are having the dogs destroyed?" "Yes, it is I." "What is their offence, king of men?" "They have been gnawing the straps and the leather covering my carriage." "Do you know the dogs who actually did the mischief?" "No, I do not." "But, your majesty, if you do not know for certain the real culprits, it is not right to order the destruction of every dog that is seen." "It was because dogs had gnawed the leather of my carriage that I ordered them all to be killed." "Do your people kill all dogs without exception; or are there some dogs who are spared?" "Some are spared,--the thorough-bred dogs of my own palace." "Sire, just now you were saying that you had ordered the universal slaughter of all dogs wherever found, because dogs had gnawed the leather of your carriage; whereas, now, you say that the thorough-bred dogs of your own palace escape death. Therefore you are following
the four Evil Courses of partiality, dislike, ignorance and fear. Such courses are wrong, and not kinglike. For kings in trying cases should be as unbiassed as the beam of a balance. But in this instance, since the royal dogs go scot-free, whilst poor dogs are killed, this is not the impartial doom of all dogs alike, but only the slaughter of poor dogs," And moreover, the Great Being, lifting up his sweet voice, said, "Sire, it is not justice that you are performing," and he taught the Truth to the king in this stanza:--
After listening to the Bodhisatta's words, the king said, "Do you in your wisdom know who it actually was that gnawed the leather of my carriage?" "Yes, sire." "Who was it?" "The thorough-bred dogs that live in your own palace." "How can it he shewn that it was they who gnawed the leather?" "I will prove it to you." "Do so, sage." "Then send for your dogs, and have a little butter-milk and kusa-grass brought in." The king did so.
Then said the Great Being, "Let this grass be mashed up in the butter-milk, and make the dogs drink it."
The king did so;--with the result that each several dog, as he drank, vomited. And they all brought up bits of leather! "Why it is like a judgment of a Perfect Buddha himself," cried the king overjoyed, and he did homage to the Bodhisatta by offering him the royal umbrella. But the Bodhisatta taught the Truth in the ten stanzas on righteousness in the Te-sakuṇa Jātaka 1, beginning with the words:--
Then having established the king in the Five Commandments, and having exhorted his majesty to be steadfast, the Bodhisatta handed back to the king the white umbrella of kingship.
At the close of the Great Being's words,  the king commanded that the lives of all creatures should be safe from harm. He ordered that all dogs from the Bodhisatta downwards, should have a constant supply of food such as he himself ate; and, abiding by the teachings of the Bodhisatta, he spent his life long in charity and other good deeds, so that when he died he was re-born in the Deva Heaven. The 'Dog's Teaching' endured for ten thousand years. The Bodhisatta also lived to a ripe old age, and then passed away to fare according to his deserts.
When the Master had ended this lesson, and had said, "Not only now, Brethren, does the Buddha do what profits his kindred; in former times also he did the like,"--he shewed the connexion, and identified the Birth by saying,
"Ānanda was the king of those days, the Buddha's followers were the others, and I myself was the dog."
58:2 No. 465.
60:1 No. 521.