The legend of the Thirumanikuzhi temple is closely associated with Lord Maha Vishnu and Mahabali Chakravarthy, the grandson of the Vishnu devotee Prahlada. It is believed that Mahabali was a rat in his previous birth. One day, while eating the ghee from a lamp in the temple's sanctum, the rat accidentally raised the lamp’s wicks that were about to burn out. Pleased with the rat’s actions, Lord Shiva granted it a boon, stating that it would be reborn in the family of Asura (demon) kings. This is how Mahabali Chakravarthy came into existence.
Mahabali was known for his charitable nature and was always ready to assist anyone in need. His generosity and power, however, made the celestial gods jealous. They sought the help of Lord Maha Vishnu to bring about his downfall. Lord Maha Vishnu took the avatar of "Vamana Brahmmachari" to destroy Mahabali. Vamana approached Mahabali and requested three feet of land, which Mahabali readily agreed to give.
In response, Lord Maha Vishnu took his "Thiruvikrama" avatar and measured the entire earth with a single step. With his second step, he covered the entire space. When it was time for the third step, Mahabali, having no land left to offer, humbly offered his head. Pleased with Mahabali's devotion, Lord Maha Vishnu pushed him down into the underworld (Pathalam) and made him one of the "Chiranjeevis" — the immortals.
The temple's legend also involves Lord Maha Vishnu coming to this place as a bachelor (Brahmachari). After completing his "Vaamana Avatar," Lord Vishnu worshipped Lord Shiva here to seek respite from his "Brahmhatthi Dosham." Since Vamana was of small stature and could not see Lord Shiva’s face, Lord Shiva took a smaller form and appeared inside a pit (called “kuzhi” in Tamil) to allow Maha Vishnu to worship him.
Since Lord Maha Vishnu worshipped Lord Shiva here as a bachelor (Maani in Tamil) and Lord Shiva appeared inside a pit (kuzhi), the place came to be known as "Thiru Manikkuzhi" (with "Thiru" as a respectful prefix).