When Brahmadatta was the king of Bārāṇasī, the Bodhisatta was born into a brahmin family in a certain Kāsi village. Nearby was a deep well at which the villagers would draw water and leave some for wild animals to drink. The Bodhisatta, having drawn some water for himself, drank it, and washed his hands; then he noticed a thirsty monkey. He drew water from the well and filled the trough for him.
The monkey drank and grimaced, to frighten away the Bodhisatta. As the Bodhisatta got up to go, the monkey dropped dung on his head from the branch where he was sitting, and ran off into the forest. The Bodhisatta washed, and went his way.
The Buddha identified the monkey as Devadatta and the brahmin as himself. (J.ii.69)