Long ago, Vishnu who is also known as Janardhana, had waged a war lasting sixteen thousand years with the Asuras. At the end of the battle, overcome with fatigue, he went to sleep, in a standing posture, with his head supported by the tip of his peerless bow. As fate would have it, he fell into a really deep sleep, unaware of his surroundings and stood as one whose life had become extinct.
When the Devas and the divine sages beheld this, they grew very worried. For who would protect the world if the great protector is sleeping? Besides, for the Yagna (sacrifice) to be conducted in heaven, Vishnu's presence was essential. Even Brahma and Shiva who were present, were concerned about Vishnu's state.
Shiva turned to Brahma and said, "The scriptures say that waking someone who is in deep sleep is a great sin. However, desperate times call for desperate measures. Among your myriad creations, I remember that there was a tiny beetle, belonging to the Chel species. Let it eat the bowstring from the bottom. When the bow recoils from its tense state, the noise will wake Vishnu up."
Accordingly Brahma commanded the insect to break the bowstring. When the string broke, the bow snapped erect with a noise, that sounded like that made at the end of the world. All those present were frightened by that terrible sound. Ill omens appeared in the air. The sun sank before its appointed time. All creation started acting in a manner inconsistent with their normal behavior.
When the Devas looked to see if Vishnu had woken, a gory sight met their eyes. The recoiling bow tip had beheaded Vishnu! Only his lifeless torso stood there, a grim sight that shook the beholders to the core of their being.
Brahma said, "The only thing we can do during this evil time, is to pray to Devi. She is the life force behind the universe. Everything that happens is according to her will. If Vishnu has been beheaded, she must have caused it to happen. Only she can show us the path from our present predicament."
Accordingly, all the Devas, Shiva and Brahma, started praying to Shakti. They sang many hymns extolling her prowess, praising the great love she has for all her creations. They praised her as the force behind all creation, one who controls the fate of the universe.
At last, an incorporeal voice shouted from the sky, "O Devas, you have nothing to worry. You have worshiped me as per the method described in the Vedas. I am very much pleased. There is a reason why I caused Vishnu's head to be cut off from his body. Listen to this story."
Long ago, there a great Asura king named Hayagreeva performed a great penance directed to me on the banks of the river Saraswati. When I appeared before him, he asked for the boon of immortality. When I told him that it was impossible, he then asked for a boon that he may be killed only by a creature with the face of a horse.
Emboldened by my boon, he has oppressed the world for a long time. Nobody is safe from his marauding forces. I have decided that Vishnu should slay him. Let Brahma fit the body of Hari (Vishnu) with that of a horse. You shall accomplish my will by this means."
Acting on the instructions from Devi, Brahma instantly beheaded a horse with a sword. He then fitted Vishnu with its head. Vishnu was transformed by the grace of Devi into a wondrous creature, of immense strength, with the body of a man, and with the head of a head. He was known asHayagreeva (horse-headed).
At the end of a vicious battle, the Asura Hayagreeva was killed by Vishnu, in his form as Hayagreeva. By the Devi's grace, Vishnu regained his previous form at the end of this battle