Baba Ram Rai was the eldest son of the Seventh Sikh Guru, Guru Har Rai Ji who had 2 other children. Guru Harkrishan was the youngest amongst the three siblings. Baba Ji's sister Sarup Kaur was almost four years older than him.
Ram Rai was nine years older than Guru Harkrishan. Baba Ji was born in a palace called Sheeh Mahal. It is said that this palace, the residence of Guru Har Rai, was constructed on the model of the Sheesh Mahal of Jaipur.
After Aurangzeb had imprisoned his father and had finally wrested the Mughal throne away from his eldest half-brother Dara Shikoh (who their father Shah Jahan had preferred as the next Emperor), Aurangzeb was goaded, by members of his Court, into accusing Guru Har Rai of lending Dara Shikoh support.
Aurangzeb demanded that Guru Har Rai make an appearance in Delhi. Instead, Guru Sahib sent his eldest son, Ram Rai, to Delhi. Ram Rai was well received by Aurangzeb. He not only satisfactorily responded to all of Aurangzeb's concerns, but he also impressed the Emperor with his cleverness. As a result, Ram Rai was asked to stay on as a state guest for some period.
Ram Rai mis-quotes Gurbani
One day, after prodding by some of the Ulema, Aurangzeb asked, why Sri Guru Nanak had criticized Islam in salok "Mitti Musalman Ki"? Ram Rai satisfied the assembled Muslims by saying that the line had been copied incorrectly and that the actual writing was correctly "Mitti Baimaan Ki" and not "musalman ki" as was written.
Though Ram Rai was well-blessed with all powers and strictly instructed only to explain Guru's position, but to sooth the minds of his host he choose to mis-interpret Guru Nanak's writings which was completely forbidden. Further, it is said that he performed miracles for Aurangzeb's pleasure.
The Guru "disowns" Ram Rai
When Guru Har Rai Ji heard of this incident, he forbade Ram Rai from ever returning home. Guru's word in Gurbani is absolute divine revelation and not subject to any modifications by anyone. Miracles although recognized by Sikh faith, are actively discouraged. Their exposition or display is considered arrogance (competing with Vaaheguru's powers).
Though Ram Rai managed to please Aurangzeb, Guru Har Rai Ji forbade all Sikhs from ever associating with Ram Rai. Aurangzeb gave Ram Rai a jagir of four villages in the Doon area as a reward. He died there in sunmat 1788. Because of Ram Rai's Dehra, Duun came to be popularly known as Dehradun.
Young Harkrishan become Guru at age 5
A historical katha suggests that when Ram Rai was engrossed in meditation, the neighbouring masands mistook him for dead and cremated his body. For this reason, Mata Punjab Kaur sought punishment of the masands from Kalgidharr patshah. Today there is a small following of Ram Rai. However, by Guru Har Rai's hukam, all Sikhs are forbidden any association with Ram Rai's followers.
Therefore instead of Ram Rai, Guru Harkrishan was installed as Guru at the tender age of five years and three months at Kiratpur. At the time of installation of Harkrishan as Guru, Ram Rai his elder brother was in the court of Emperor of Delhi.
He after learning that Guruship was passed to his younger brother became furious and envious of Guru Harkrishan. He requested the emperor to summon Harkrishan to Delhi and ask him to perform the miracles similar to what he had performed. Ram Rai knew that Guru Harkrishan had taken a vow to never appear before the emperor as it was also an order given to him by his father Guru Har Rai.
Another version of his last years
Shuned by all Sikhs he went to Srinagar Garwaal and became a great friend of Raja Fateh Chand. It is thought that he influenced Raja Fateh Chand to annex some territory of Raja Medani Prakash. He had many followers known as Masands. As Baba had no children to inherit his property his Masands were trying their best to occupy the Dera. Baba Ram Rai shifted to Dehradoon. There he was cremated alive while in deep meditation. When his wife Panjab Kaur complained about this to Guru Gobind Singh he went to Dehradoon and gave severe punishment to the guilty Masands.