The original 39th Native Infantry formed from the old Aligarh Levy was disbanded after disgracing itself at the Rawalpindi Review in 1888. Lord Dufferin the Viceroy was taking the salute. Unfortunately the marchpast took place in torrential rain and the 39th were following the cavalry and the elephant batteries of the artillery and having to negotiate deep mud. Most of the men lost their shoes and fell out to retrieve them and it seems that the native officer bearing the Queen's Colour used his flagpole to search for his footwear.
In January 1891, the 39th (The Garhwali) Regiment of Bengal Infantry was formed from the 2nd battalion 3rd Gurkhas. This was a battalion made up entirely of Garhwalis following an order of 1887. In 1892 they were given the title of 'Rifles'. Another regiment of Garhwalis was raised in 1901 called the 49th but shortly afterwards became the 2nd battalion of the 39th, making them, apart from the Gurkhas, the only two-battalion regiment in the Indian Army.
The 39th was in the Meerut division in WW1. They were part of 20 Brigade with 2 Leicesters and 2/3 Gurkha Rifles. They suffered heavy casualties in Flanders and were recalled to their base at Lansdowne from where they went to Mesopotamia. Two more battalions were raised during the war and in 1921 they were titled the 39th Royal Garhwal Rifles. In 1922 they were they only Indian Infantry regiment to remain intact without being amalgamated. They were renumbered 18th with the 4th battalion becoming the training battalion (10th).
During the Second World War, the first three battalions served in different parts, the 2nd being captured by the Japanese in Singapore in 1942. Three more battalions were raised, one of which, the 5th, was also captured in 1942. On Partition the Royal Garhwali Rifles were allocated to India. Having no Muslims to transfer, it had a relatively trouble-free handover.