Hiranyakshipu, the asura king, got arrogant after he got boons from Brahma, which nearly made him invincible. He troubled the devas (celestial deities) and they prayed to Vishnu for rescue. Vishnu was ready to take the Narasimha avatar to slay the asura king. The devas pleaded with Vishnu to assume the form before he could take it. Vishnu showed them the avatar, but not satisfied merely one vision, the devas and sages pleaded with him to show it again. Vishnu appeared in three forms of himself standing, sitting, and resting posture at Thirukoshtiur. Since, Vishnu showed his form after hardship (called Thirukkai in Tamil) of Devas, the place came to be known as Thirukoshtiur.
