Ucchi Pillayar Temple, Rockfort

Ucchi Pillayar Temple is a 7th-century Hindu temple, one dedicated to Lord Ganesha located a top of "Rockfort", Trichy, Tamil Nadu, India.
According to legend, this rock is the place where Lord Ganesha ran from King Vibishana, after establishing the Ranganathaswamy deity in Srirangam. Tiruchirapalli Rock Fort is also fondly called as "Malaikottai" in Tamil.
Architecture.
The Rock Fort temple stands tall perched atop a rock. The smooth rock was first cut by the Pallavas but it was the Nayaks of Madurai who completed both the temples under the Vijayanagara empire.
The temple is situated at the top of the rock. The temple is mystic in its nature with an awe-inspiring rock architecture. The Ganesha temple is much smaller with an access through steep steps carved on the rock and provides a stunning view of Trichy, Srirangam and the rivers Kaveri and Kollidam. Due to its ancient and impressive architecture created by the Pallavas, the temple is maintained by the Archaeological department of India.
History of the Vinayaka temple.
Vibhishana, was the younger brother of the Asura King Ravana who ruled Lanka. Lord Rama in the epic of Ramayana rescues his wife Sita, who was kidnapped and held by Ravana, with the help of Sugriva and Hanuman defeated him. In this war, the moral and truth-abiding brother of Ravana, Vibishana aids Rama in his battle against his brother. Ultimately Rama wins the war and as a token of love, he gives Vibishana a "vigraham" (idol for worship) of Lord Ranganatha, a form of Vishnu.
Vibhishana, though he supported Rama, was basically an Asura, hence the Devas (who are arch rivals to Asuras as per Hindu mythology) wanted to stop this idea of an Asura taking Lord's supreme form to his Kingdom. They request the help of the Remover of obstacles and God of learning, Lord Vinayaka and the Lord accepts the plan. Vibhishana, while on his back to his Kingdom, goes through Trichi, and wanted to take his bath in the river Kaveri and do his daily rituals. However, he is perplexed as the deity, once kept in land, can never be removed and has to be in that place forever.
As a solution, Vibishana tries to find someone to hold the deity while he was taking bath. He finds the Lord Vinayaka under disguise of a cowherd boy. As per the plan, when Vibishana is fully into water, Vinayaka takes the deity and keeps it firmly in sand, in the banks of kaveri. On seeing this, the angry Vibhishana chases the boy, to punish him, and boy keeps running and climbs over the rock near the Kaveri bank. Vibhishana finally reaches the boy and hits him on the fore-head. One can see a pit in the forehead of the idol even today. The little boy then reveals himself to be Vinayaka. Vibishana immediately apologizes and the Lord gives him his blessings, reveals that the idol is destined to remain in Srirangam and sends him off to Lanka. This is similar in many regards to the story of Lord Ganesha in Gokarna with Ravana in the same Ramayana period.
The place in which the Ranganathan deity was kept was later covered in deep forests, due to disuse and after a very long time, it was discovered when a Chola king chasing a parrot found the deity accidentally. He then established the Ranganathaswamy Temple, Srirangam as the largest temple complexes in the world. Meanwhile, the Pallavas built the Vinayaka temple and the Thayumanaswamy temple, in the rock which Vinayaka used to escape Vibishana.
Uchi Pillayar is always associated with Manicka Vinayagar at the foothills. It is a general worship practise to pray obeisance with Manicak Vinayagar before visiting Uchi Pillayar.