King Bali was an asura (demon) king. He had conquered heaven. He was a kind ruler but also very ambitious.To appease the gods he performed a yagna (fire sacrifice). His yagna was so successful that even the gods were scared to appear before him and grant him a boon in the fear that he might ask something which is beyond their capacity. Some gods asked Vishnu to check King Bali’s power.
At Indra’s request,Vishnu took birth as a Brahmin boy and went to the place where Bali was performing the sacrifice.This was the Vamana (dwarf) Avatar of Lord Vishnu.
Lord Vishnu reached King Bali’s court dressed as a priest. Despite being warned by his guru Shukra that this was Vishnu in disguise, Bali told him to ask for anything he wanted.
The priest said, “You are the ruler of the three worlds: the Earth,the world above the skies and the underworld. Would you give me the space that I could cover with three steps?” King Bali laughed as the priest’s request seemed strange to him and all the courtiers, but King Bali granted it thinking that a dwarf could not cover much ground in three strides.
In order to fulfill the bequest, Bali would have to pour water from a container with a spout. Shukra make one last attempt by blocking the spout of the container disguised as an insect but the priest pushed the insect away with a blade of grass, blinding it in one eye.
Once the request was granted to him, the priest,who was none but Vishnu in disguise, transformed himself into Vishwaroopa (the universal form) and submerged the entire world (Mrityu-loka) with one step and heaven(Swarga-loka) with the second step. But for the third step,there was no respectable place to put his foot down and so he asked Bali for some place to put down his foot so that the boon could be fulfilled. King Bali offered his head for the purpose.Thereupon Vishnu resumed his Vamana form and granted salvation to Bali by placing his tiny foot on Bali’s head.
After this, Vishnu restored the rule of the gods on the heaven and earth and sent Bali to rule the nether-world.