Pleased by Ram Rai’s performance, Aurungzeb had become his patron. One of the emperor’s friends, Raja Fateh Shah, King of Garhwal, allotted some land in the Doon valley to Ram Rai. Removed from the line of Sikh Gurus, Ram Rai decided to establish his “dera” or camp here. Hence the name of the town that grew up around the camp and soon began to expand with large number of devotees of Ram Rai who began arriving in large numbers from Punjab. When he passed away in 1687, Aurungzeb built a grand cenotaph to honour his memory.