Lord Shiva wanted to test the King's charitable disposition and his devotion. Shiva and his Shivaganas appeared in the guise of sanyasis. He sent all his followers to the dancing girls houses at Thiruvannamalai. He himself then went to the palace and asked the King for a dancing-girl. As all the dancing girls in the city were already engaged the King could find none for him. Sallammadevi, his junior queen, offered herself to the sanyasi, if the King had no objection. The King readily accepted and sent her to the devotee. The devotee pretended to sleep on a cot. As soon as the queen touched him, to her dismay, he transformed into a child. She took the child to the King. No sooner did she hand it over to him than it disappeared mysteriously.
The king had no child and Lord Shiva promised to perform his last rituals.The king died on a Masi Magam day and as per the promise, Lord Shiva performed his last rites.Lord Shiva further blessed the king by saying that whoever takes a bath in the sea during Masi Magam will get ‘Moksha.’ It is believed that every year the Lord Shiva visits the sea to perform the last rites of the king Vallala.
To commemorate this incident Arunachaleswarar is taken to Pallikondapattu every year on the day of Maga Nakshatram in the Tamil month of Masi and the festival of obsequies is being performed. King Vallala of this legend may be taken to be the Hoysala King Vira Vallala III who is referred to in the inscriptions in the temple and who reigned in the fourteenth century.