Once on a time when Brahmadatta was reigning in Benares, the Bodhisatta became his minister. In those days there was a dog which used to go to the stall of the elephant of state, and eat the gobbets of rice which fell where the elephant fed. Haunting the place for the food’s sake, the dog grew very friendly with the elephant, and at last would never eat except with him. And neither could get on without the other. The dog used to disport himself by swinging back wards and forwards on the elephant’s trunk. Now one day a villager bought the dog of the mahout and took the dog home with him. Thence forward the elephant, missing the dog, refused either to eat or drink or take his bath; and the king was told of it. His majesty dispatched the Bodhisatta to find out why the elephant behaved like this. Proceeding to the elephant – house, the Bodhisatta, seeing how sad the elephant was, said to himself, “He has got no bodily ailment; he must have formed an ardent friendship, and is sorrowing at the loss of his friend.” So he asked whether the elephant had become friends with anyone.
“Yes, my lord,” was the answer; “there’s very warm friendship between him and a dog.” “Where is that dog now?” “A man took it off.” “Do you happen to know where that man lives?” “No, my lord.” The Bodhisatta went to the king and said, “There is nothing the matter with the elephant, sire; but he was very friendly with a dog,  and it is missing his friend which has made him refuse to eat, I imagine.” And so saying, he repeated this stanza:-
No morsel can he eat, no rice or grass;
And in the bath he takes no pleasure now.
Methinks, the dog had so familiar grown,
That elephant and dog were closest friends.
“Well,” said the king on hearing this; what is to be done now, sage?” “Let proclamation be made by beat of drum, your majesty, to the effect that a man is reported to have carried off a dog of which the elephant of state was fond, and that the man in whose house that dog shall be found, shall pay such and such a penalty.” The king acted on this advice; and the man, when he came to hear of it, promptly let the dog loose. A way ran the dog at once, and made his way to the elephant. The elephant took the dog up in his trunk, and placed it on his head and wept and cried, and, again setting the dog on the ground, saw the dog eat first and then took his own food.
“Even the minds of animals are known to him,” said the king, and he loaded the Bodhisatta with honours.