The temple was built in 1859, three and a half centuries after the demise of Ramdev Pir in 1459 CE.[3] According to a legend, a Hindu man in Tando Allahyar took a vow that if he was blessed with a child, he will arrange a Mela (fair) of Rama Pir in Tando Allahyar. As his wish was fulfilled, he brought an earthen lamp from the original temple of Rama Pir in Ramdevra in today's Rajasthan, India to Tando Allahyar in today's Pakistan and built a temple here.[4][3]