The Bodhisatta was born as a sprite, in a clump of kusa-grass. Hard by was a mukkhaka-tree in which lived a Tree-sprite. One day the king's carpenter, looking for a suitable pillar for the king's one-pillared palace, reluctantly decided to fell the mukkhaka. Learning of the Tree-sprite's imminent danger, the Bodhisatta assumed the shape of a chameleon and deceived the carpenter in such a way that he saw the mukkhaka as all rotten and of no use for his purpose.
The story was told in reference to one of Anāthapindika's friends. He was of low rank and poor, and Anāthapindika's other friends protested against such intimacy. But one day the poor friend saved Anāthapindika's house from being burgled. The Buddha related the story to show how each, according to his strength, could help a friend in need (J.i.441ff).
Ananda was the Tree-sprite. The story is often quoted (E.g., J.iv.77) to show the value of a good friend.