In the past, during the wedding of Ammaiyappar in Kailayam, the earth's balance shifted with the north direction sinking and the south direction rising. To restore balance, Sage Agathya came to the southern region. When he arrived at Trikuta Hill, he tried to enter the Perumal temple there, but the Vaishnavites prevented him because he was a Saiva. Sage Agathya prayed to Tirumala, asking for the realisation that Arya (Vishnu) and Shiva are one. He then placed his hand on his head and chanted "curukuka curukuka," turning the deity into a Shivalingam. After this transformation, he established Perumal in Sivalaperi.
When Lord Alaghar saw the beauty of Sivalaperi, he stayed there and attained eternal life. The goddess Mahalakshmi, charmed by the place, also came and united with Perumal. This is why the place is called 'Sri Valam Vanda Peri,' meaning the place where Mahalakshmi came and joined Perumal.