The Jataka, Vol. III, tr. by H.T. Francis and R.A. Neil, , at sacred-texts.com
"The righteous king," etc.—The Master told this tale while dwelling in Jetavana, concerning the Kosala king's favour to a stranger. At one time, the story goes, that king showed no favour to his old warriors who came to him in the usual way, but gave honour and hospitality to strangers coming for the first time. He went to fight in a disturbed frontier province: but his old warriors would not fight, thinking that the new-corners who were in favour would do so; and the new-corners would not, thinking that the old warriors would. The rebels prevailed. The king, knowing that his defeat was owing to the mistake he had made in showing favour to new-comers, returned to Sāvatthi. He resolved to ask the Lord of Wisdom whether he was the only king who had ever been defeated for that reason: so after the morning meal he went to Jetavana and put the question to the Master. The Master answered, "Great King, yours is not the only case: former kings also were defeated by reason of the favour they showed to new-corners," and so, at the king's request, he told an old tale.
Once upon a time in the city of Indapattana, in the kingdom of the Kurus, a king was reigning named Dhanañjaya, of the race of Yudhiṭṭhila. The Bodhisatta was born in the house of his family priest. When he grew up, he learned all the arts at Takkasilā. He returned to Indapattana, and at his father's death he became family priest to the king and his counsellor in things temporal and spiritual. His name was called Vidhūrapaṇḍita.
King Dhanañjaya disregarded his old soldiers and showed favour to new-comers. He went to fight in a disturbed frontier province: but neither his old warriors nor the new-comers would fight, each thinking the other party would see to the matter. The king was defeated. On his return to Indapattana he reflected that his defeat was due to the favour he had shown to new-comers.  One day he thought, "Am I the only king who has ever been defeated through favour shown to new-corners, or have others had the same fate before? I will ask Vidhūrapaṇḍita." So he put the question to Vidhūrapaṇḍita when he came to the king's levee.
The Master, declaring the reason of his question, spoke half a stanza:
"Brahmin, dost know in whose lone heart much bitter sorrow lies?"
Hearing him, the Bodhisatta said, "Great king, your sorrow is but a trifling sorrow. Of old, a brahmin goatherd, named Dhūmakāri, took a great flock of goats, and making a pen in the forest kept them there: he had a smoking fire and lived on milk and the like, tending his goats. Seeing some deer of golden hue who had come, he felt a love for them, and disregarding his goats he paid the honour due to them to the deer. In the autumn the deer moved away to the Himālaya: his goats were dead and the deer gone from his sight: so for sorrow he took jaundice and died. He paid honour to new-comers and perished, having sorrow and misery a hundred, a thousand times more than you." Bringing forward this instance, he said,
Smelling the smoke, a herd of deer, by gnats sore pestered, come The deer have all attention now; his goats receive no care,  But now the gnats have left the wood, the autumn's clear of rain: The brahmin sees the deer are gone and all his goats are dead: So he who disregards his own, and calls a stranger dear,
Kept smoking fire by night and day in forest dwelling-place.
To find a dwelling for the rains near Dhūmakāri's home.
They come and go untended all, and so they perish there.
The deer must seek the mountain-heights and river-springs again.
Jaundice attacks him worn with grief, and all his colour's fled.
Like Dhūmakāri, mourns alone with many a bitter tear.
Smelling the smoke, a herd of deer, by gnats sore pestered, come
The deer have all attention now; his goats receive no care,
 But now the gnats have left the wood, the autumn's clear of rain:
The brahmin sees the deer are gone and all his goats are dead:
So he who disregards his own, and calls a stranger dear,
Such was the tale told by the Great Being to console the king. The king was comforted and pleased, and gave him much wealth. From that time onward he showed favour to his own people, and doing deeds of charity and virtue, he became destined for heaven.
After the lesson, the Master identified the Birth: "At that time the Kuru king was Ānanda, Dhūmakāri was Pasenadi, king of Kosala, and Vidhūrapaṇḍita was myself."