The Bodhisatta was once a king. He was very righteous, and soon after he was crowned he banned animal sacrifice. Some goblins were angry about this and they sent one particularly savage goblin to kill the Bodhisatta with a blazing mass of iron, as big as the roof of a house. As the goblin appeared at the head of the Bodhisatta’s bed, ready to strike, the throne of Indra, king of the gods, became warm. When Indra divined the reason, he grabbed his thunderbolt and stood over the goblin. The Bodhisatta woke up and saw the goblin hovering over him, though Indra was invisible. The Bodhisatta asked if he was there to protect him or kill him. The goblin answered honestly, but said he had changed his mind because he feared Indra. From then on, all goblins would protect him.
In the Lifetime of the Buddha
One day some of the Buddha’s disciples sat around discussing how great the Buddha was: how he kept a simple life, was kind to all (even nagas and garudas), converted many people, and always lived for the benefit of the world. When the Buddha heard their discussion, he told them this story so they knew that he had also acted in the interest of others in the past.
Indra was an earlier birth of Anuruddha, one of the Buddha’s top disciples.