This story is a part of the Hindu text called Shrimad Bhaagavad Purana, which shows the importance of Bhagti, true prayer and true devotion.
An elephant named Gajendra, was the king of a herd of elephants, including many queen elephants with whom he used to bathe and play in a lake. Gajendra was proud to be the king elephant. One hot day while he was arrogantly bathing in the lake with its heard, suddenly a crocodile from below caught him by the foot, tried to pull the elephant to the bottom of the lake, and would not let go of it.
Gajendra fought hard to free himself from the clutches of crocodile but he was unable to get rid of the crocodile. When other members of its herd (friends, queen elephants, the family members, and relatives) saw Gajendra fighting futilely to release himself from the jaws of death, fled. In other words, realizing that death was coming close, they all ran away and left Gajendra alone.
When all hope of rescue faded away and death was staring at his face, Gajendra at that stage of utter helplessness, called out to the Lord and offered him a lotus flower. To hear his plea Lord Vishnu appeared on his Garuda and destroyed the Crocodile with his Sudarshan Chakra. Hence Gajendra was instantly released from the grip of the crocodile.
Symbolisms of this Story
(1). Jeeva (the individual being, embodied being, mortal, man...), the egoistic mind is the elephant, Gajendra.
(2). The Mayaic world (Jagat, Sansaar...) is the lake (or the ocean). In this lake Jeeva plays his life's game with his spouse, children, other family members, relatives, friends, and so on.
(3). The elephant is known for its lustful nature. Similarly, the deluded ego-mind is enticed by the enchanting and mirage-like world appearance and its gross objects (Maya).
(4). The crocodile symbolically represents death that constantly hovers over our head. We fear death, which ends everything unexpectedly. In addition, the crocodile also symbolizes many sufferings and difficulties Jeeva faces in life.
(5). When we are caught in the clutches of death, there is no one who can protect us - friends disappear, relatives flee, and even our own body fails us. Hence at the end like the elephant in the story, we are all alone and the only the name of Lord can rescue us. In the moment of utter surrender, God rushes to our aid, saves us and releases us from the torture of death – this is liberation or Mukti or Moksha that we all aim for in this life.
(6). Last but not least, as goes in the story, so long the elephant tried himself to free itself from the crocodile, it was not freed from the jaws of the crocodile. The moment it put the onus of saving it on the Lord, or the moment it thought of the Lord (Naam, Shabad, Hukam...) as its only support or refuge, He rescued him.