The Jataka, Vol. II, tr. by W.H.D. Rouse, , at sacred-texts.com
"What time the nearness," etc.-- This story the Master told whilst living at Jetavana, about Kokālika 1. The circumstances of this story will be given in the Thirteenth Book, and the Takkāriya-jātaka 2. Here again Kokālika said, "I will take Sāriputta and Moggallāna with me." So having left Kokālika's country, he travelled to Jetavana, greeted the Master, and went on to the
[paragraph continues] Elders. He said, "Friends, the citizens of Kokālika's country summon you. Let us go thither!!" "Go yourself, friend, we won't," was the answer. After this refusal he went away by himself.
The Brethren got talking about this in the Hall of Truth. "Friend! Kokālika can't live either with Sāriputta and Moggallāna, or without them! He can't put up with their room or their company!" The Master came in, and enquired what they were all talking about together. They told him. He said, "In olden days, just as now, Kokālika couldn't live with Sāriputta and Moggallāna, or without them." And he told a story.
Once upon a time, when Brahmadatta was king of Benares, the Bodhisatta was a tree-spirit living in a wood. Not far from his abode lived another tree-spirit, in a great monarch of the forest. In the same forest dwelt a lion and a tiger. For fear of them no one durst till the earth, or cut down a tree, no one could even pause to look at it, And the lion and tiger used to kill and eat all manner of creatures; and what remained after eating, they left on the spot and departed, so that the forest was full of foul decaying stench.
The other spirit, being foolish and knowing neither reason nor unreason, one day bespoke thus the Bodhisatta:
"Good friend, the forest is full of foul stench all because of this lion and this tiger. I will drive then away."
Said he, "Good friend, it is just these two creatures  that protect our homes. Once they are driven off, our homes will be made desolate. If men see not the lion and the tiger tracks, they will cut all the forest down, make it all one open space, and till the land. Please do not do this thing! "and then he uttered the first two stanzas:
"But when your bosom friend does more increase
The measure of your peace,
Let your friend's life in everything right through
Be dear as yours to you."
When the Bodhisatta had thus explained the matter, the foolish sprite notwithstanding did not lay it to heart, but one day assumed an awful shape, and drove away the lion and tiger. The people, no longer seeing the footmarks of these, divined that the lion and tiger must have gone to another wood, and cut down one side of this wood. Then the sprite came up to the Bodhisatta  and said to him,
"All, friend, I did not do as you said, but drove the creatures away; and now men have found out that they are gone, and they are cutting down the wood! What is to be done?" The reply was, that they were
gone to live in such and such a wood; the sprite must go and fetch them back. This the sprite did; and, standing in front of them, repeated the third stanza, with a respectful salute:
This request they refused, saying, "Go away! we will not come." The sprite returned to the forest alone. And the men after a very few
(lays cut down all the wood, made fields, and brought them under cultivation.
When the sprite had ended this discourse, he declared the Truths and identified the Birth:--"Kokālika was then the foolish Sprite, Sāriputta the Lion, Moggallāna the Tiger, and the wise Sprite was I myself."
244:1 Kokālika was a follower of Devadatta.
244:2 No. 481.