Patanjali is widely believed to have been a "Siddhar" rishi (sage) who lived in the state of Tamilnadu in South India about 2500 years ago. "Siddhars", literally meaning the perfected ones, were yogis with special powers accomplished through their meditation practice. They were especially skilled at medicine. He is said to have attained "Mahasamadhi" at the Brahmapureeswarar temple in Tirupattur, South India, where there is a shrine constructed somewhere between the 7th and the 9th centuries C.E.
Patanjali is also well known for his treatise on Sanskrit grammar (the Mahābhāṣya commentary on Panini's rules of grammar) and his commentary on the Charaka Samhita, one of the principal texts of Ayurveda. He is, therefore, said to have excelled in Yoga, Sanskrit and also medicine.
Patanjali is also featured in the Sthala Puranam (Legend of the Shrine/Temple) of the famous Chidambaram temple in Tamilnadu. The legend says that he and Vyagrapada (he who has the feet of a tiger) traveled independently to Chidambaram to get a darshan (view) of Shiva's cosmic dance.
While the above information of Patanjali as a Siddhar is historically true, there is yet another legend (purely fictional), depicting him as an avatara of Ādisesha, Vishnu's thousand-headed serpent who also serves as his umbrella and bed.
The legend of Patanjali
In its original form, this legend is not about Patanjali teaching the Yoga Sutras. It is about him teaching the Mahābhāṣya—his monumental commentary on Sanskrit grammar. The story was created to emphasize that the teachings were precious, almost lost, and required a superhuman effort to save.
Here is the story
According to legend, Lord Vishnu was once seated on Adishesha, the lord of serpents, watching the captivating cosmic dance of Lord Shiva. Vishnu was so totally absorbed and enchanted by the dance that his body began to vibrate to its rhythm. This intense vibration caused him to become incredibly heavy, making it difficult for Adishesha to bear his weight and causing the serpent to gasp for breath. As soon as the dance ended, Vishnu's body became light again. Amazed, Adishesha asked what had happened. Vishnu explained that Shiva's graceful dance had created vibrations in his own body, making it heavy. Inspired, Adishesha expressed a desire to learn this dance so he could please Vishnu in the same way. Vishnu predicted that soon, Shiva would grace Adishesha for this very purpose, and that Adishesha would be born on Earth to author a great commentary on grammar.
With this boon, Adishesha began searching for a suitable mother. He spotted a yogini named Gonika offering prayers and water to the Sun God, praying for a worthy son to whom she could pass on her knowledge. Seeing her devotion, Adishesha fell as a tiny snake into her cupped hands. He then took human form and begged her to accept him as her son. She named him Patanjali—Pata meaning "fallen" and Anjali meaning "folded hands."
Later, as a great Master, Patanjali decided to teach the commentary on grammar to exactly 1,000 disciples (perhaps due to his having a 1000 heads- sahasra shirasam shwetam- in his original form). He set a strange condition: he would teach from behind a curtain, and no student was to lift it or leave the hall until the session was over. He did not want them to see his divine form as the thousand-headed serpent, whose fiery breath would be too intense for mortals. The lessons began, and the students were spellbound by the brilliance of the teaching, which seemed to come from a single source but flowed to each of them individually.
However, during one session, curiosity got the better of the students. One disciple, needing to relieve himself, quietly slipped out of the hall. Another student, overcome by curiosity to see the master, lifted the curtain. In that instant, Patanjali's fiery breath incinerated all 999 students present, reducing them to ashes. Patanjali was profoundly sad that his knowledge would die with him.
Just then, the single disciple who had left the hall returned. Patanjali was relieved to find one survivor to whom he could pass on the lineage of knowledge. However, since this disciple had violated the rule of leaving the hall without permission, Patanjali cursed him to become a Brahmarakshasa—a type of spirit or ghost of a Brahmin or a learned person who has committed misdeeds. The curse came with a condition for liberation: the spirit would hang on a banyan tree and ask a specific grammatical question to anyone passing by. He would be released only when someone could provide the correct answer.
The Brahmarakshasa hung on the tree, asking his question to passersby. Those who could not answer were eaten by him. This continued for many years until Patanjali himself, taking pity on the spirit, offered himself as a student. He answered the grammatical question correctly. As Patanjali had decreed, receiving the correct answer broke the curse, and the Brahmarakshasa was liberated from his ghostly form.
To ensure this precious knowledge of grammar was not lost again, Patanjali, through this disciple, sat on a rock and wrote out the teachings. It is said that he wrote uncontrollably for days without sleep. When he finally became exhausted and fell asleep, a goat came and ate several of the leaves he had written on. Patanjali eventually awoke, gathered the remaining leaves, and compiled them into what is known as the Mahābhāṣya (the Great Commentary), though some parts remained lost forever due to the goat.