To create this story, I worked with the Wikipedia article: Gajendra Moksha, adding details from other Wikipedia articles and from the Bhagavata Purana translation at the Bhaktivedanta VedaBase.
The Liberation of Gajendra the Elephant
Gajendra Moksha, The Liberation (Moksha) of Gajendra, is a legend from the Bhagavata Purana, which narrates the adventures of the god Vishnu.
There was once an elephant named Gajendra who lived in a lovely garden located on Mount Trikuta, the "Three-Peaked Mountain," in ancient India. Gajendra ruled over all the other elephants in the herd.
On a hot day, Gajendra proceeded with his herd to a lake to cool off in its fresh waters. Suddenly a makara, which is a sort of crocodile, attacked Gajendra and caught him by the leg. Gajendra tried for a long time to escape from the crocodile's clutches. All his family, relatives and friends gathered around to help him, but in vain. The crocodile simply wouldn't let go.
When they concluded that it was Gajendra's time to die, the other elephants left him alone. Gajendra trumpeted in pain and helplessness until he was hoarse. The struggle seemed to go on forever (some people say that the crocodile held Gajendra's foot for over a thousand of years!), and when Gajendra had finally expended all his strength, he called to the god Vishnu to save him, holding a lotus up in the air as an offering.
Hearing his devotee's call, Lord Vishnu rushed to the scene. As Gajendra sighted the Lord coming, he lifted the lotus even higher with his trunk. Pleased by this sight, Vishnu used his sacred discus, the Sudharshana Chakra, to separate the crocodile's head from its body. Gajendra then prostrated himself before Vishnu in reverent gratitude.
Vishnu explained that, in his previous birth, Gajendra had been a famous king named Indradyumna, but when he had insulted the great sage Agastya, Agastya cursed him. "Because of your Ahamkara (egoism), you will become an elephant," said Agastya, "and in that form you will learn the hard way that you must renounce the self and surrender yourself to Lord Vishnu."
Now that Gajendra the elephant had finally set aside his pride, totally surrendering himself to Vishnu, he was able to achieve Moksha, liberation from the cycle of rebirth, and he joined Vishnu in the heaven called Vaikuntha, the Supreme Abode of the Lord.
(500 words)
The prayer of Gajendra became a famous hymn in praise of Vishnu. You can listen to a performance here at YouTube, and you can see the transliteration and translation here: Gajendra's Prayers of Surrender to Lord Vishnu.