As the struggle was seemingly endless, when he had spent his last drop of energy, Gajendra called to his deity Vishnu to save him, holding a lotus up in the air as an offering.
Because Indradyumna had been devoted to Vishnu, the deity had him born as Gajendra and made him understand the concept of Kaivalya, which was beyond Svarga and Urdhva Loka, the realm of the gods.
Indradyumna was to attain moksha when he (as Gajendra) left all his pride and doubt, and totally surrendered himself to Vishnu.
So, Sage Agastya cursed the king that in his next birth, he would be born as an elephant, and would forget his devotional activities and previous life.
Devala explained that he could not reverse the curse; however, he informed Huhu that Vishnu would slay him as the crocodile and liberate him from the cycle of birth and death.
The symbolic meaning of Gajendra moksha is that materialistic desires, ignorance, and sins create an endless chain of karma in this world and are similar to a crocodile preying upon a helpless elephant stuck in a muddy pond.
Humans are thus stuck in a continuous cycle of death and rebirth until the day when they can look beyond everything in this creation and ultimately submit themselves to the supreme being, Vishnu.