The Bodhisatta was once an ascetic. The crown prince was a thoroughly wicked, violent man. Like grit in the eye, he was hated and feared by all. One day as he bathed in the river, a storm came and his servants threw him in the water to drown. He managed to climb to safety atop a tree trunk and as he floated downstream a snake, rat, and parrot all took refuge on the same log. In the night, the Bodhisatta, hearing the cries of the prince, jumped into the river and pulled the tree to the shore. He took all four to his home, gave them fruit, and set a fire, warming the animals before the prince since they were the weakest. Because the Bodhisatta showed no respect for his royal birth, the prince hated him.
A few days later, after recovering from their ordeal, all four set off for home, each promising to repay their gratitude to the Bodhisatta if he ever came asking. The snake and rat said they had buried gold in past lives and would take him to the spots so he could dig it up while the parrot said his kinsfolk would gather wagon-loads of rice. The prince, black of heart, made a vow to himself to kill the Bodhisatta if he ever saw him again; but concealing his intent, he said he would provide the four requisites (clothing, food, lodging, and medicine).
Sometime later the Bodhisatta decided to test all four to see if their offers were genuine. When he visited the animals, all three tried to give him what they had promised, though the Bodhisatta did not accept their gifts. Then he went to the city, where the prince was now the king. When he saw the Bodhisatta on his morning alms round he ordered his soldiers to seize him and parade him around town, beating him at every street corner, then take him out of town to behead him and impale his body on a stake.
While being beaten, the Bodhisatta did not cry out in agony, he just repeated the proverb “a log pays better reward than some men.” Some wise bystanders asked what he meant by this and the Bodhisatta told the story of rescuing their king. This filled the people with such rage they rushed the king and killed him on the spot. They flung his body in a ditch and chose the Bodhisatta as their king. He ruled righteously, giving charity and doing good deeds. And he brought the snake, rat, and parrot to live in luxury at the palace.
In the Lifetime of the Buddha
The wicked prince-cum-king was an earlier birth of Devadatta, a disciple of the Buddha who became his nemesis. When he was informed that Devadatta had made plans to kill him, the Buddha told this story to his disciples so they knew that Devadatta had also tried to kill him in the past.
The snake, rat, and parrot were earlier births of Sariputta, Moggallana, and Ananda, three of the Buddha’s top disciples.