Bali (also known as Mahabali) had obtained a boon (vara) of invincibility and (conditional) immortality from Brahma, so he could not be conquered by the gods (devas) unless he was cursed by his teacher (guru) Shukracharya. (Sukra had greater knowledge of the Vedas than the chief priest of the gods, his mastery of magic was greater, and the austerities (tapas) performed by the asuras exceeded those of the gods (devas). Thus, Bali was able to lead the asuras to victory after victory over their rivals.
The devas, led by Indra (who in the myths from the Epic Period onwards was weak and easily defeated by the demons because he did not properly keep the rules of dharma), turned to Brahma. As always (in a Vishnu myth cycle), Brahma the creator must send the gods to Vishnu, the Supreme. It was Vishnu who decided whether there was a special need to end the time of disorder and restore dharma. His goal during this time was to send King Bali to the netherworld (patala) and to help Indra regain his position as head of the devas and ruler of heaven (svarga). However, Bali was not a perfect villain and the myth had some moral ambiguities that remained unsolved.
Vishnu incarnated as a brahmin boy into the family of Aditi and her husband, the sage Kashyapa. In earlier myths, they were the cosmic parents of the gods. Yet in this myth, it was Aditi’s tapas that allowed Vamana to be born as her son. As a dwarf (vamana) brahmin, he went to the court of Bali. Although misshapen, he was still honored as a priest. His feet were washed by King Bali before his court, and he was asked to name a request. Vamana asked only for the land that he could encompass in three steps. Bali wished to be more generous and asked Vamana to name something more worthy. However, when Vamana kept asking for the same thing, the king’s sage Sukra guessed that this must be Vishnu in disguise and warned his disciple, the king. King Bali had such a high code of ethics that he would not withdraw the boon. And to the horror of all, the dwarf grew into a giant whose three strides encompassed all of creation. His teacher cursed Bali because he would not heed his teacher’s warning. Thus, the very condition that would break Bali’s boon of invincibility was fulfilled.
Garuda, the cosmic eagle and now Vishnu’s vehicle (vahana), swooped down from the heavens, bound Bali, and took him for judgment to Vishnu. Some versions even have his ancestor—Prahlada, the asura hero of the Narasimha avatara—appearing to plead for Bali. In any case, Vishnu recognized the honor and merit of Bali and granted him entry into his abode, a realm higher even than the heaven of the gods.