After Marthanda Varma's reign, Travancore's capital shifted from Padmanabhapuram to Thiruvananthapuram. Initially, the Nair Brigade headquarters moved from the old capital to the new one, then to Kollam, and eventually back to Thiruvananthapuram. Along with them, the Nair soldiers brought their revered deities. The Ganesha idols from Pazhavangady and Palayam temples were brought by the cavalry of the Nair Brigade, while Sri Hanuman was brought by the cavalry soldiers. As the temple was originally situated within the military camp, it is officially known as the O.T.C. (Officers Training Camp) Hanuman Temple.