In March 1850, the area was annexed by the British after the Second Anglo-Sikh War, and soon a subsidiary cantonment for the troops stationed at Kangra was established on the slopes of Dhauladhar, on empty land, with a Hindu resthouse or dharamshala; hence the name for the new cantonment, Dharamshala. During the British rule in India, the town was a hill station where the British spent hot summers, and around the late 1840s, when the district headquarters in Kangra became overcrowded, the British moved two regiments to Dharamshala. A cantonment was established in 1849, and in 1852 Dharamshala became the administrative capital of Kangra district. By 1855, it had two important places of civilian settlement, McLeod Ganj and Forsyth Ganj, named after a Divisional Commissioner. In 1860, the 66th Gurkha Light Infantry, later renamed the historic 1st Gurkha Rifles, was moved to Dharamshala. Soon, 14 Gurkha paltan villages were established nearby and the Gurkhas patronised the ancient Shiva temple of Bhagsunath.
Lord Elgin, the British Viceroy of India (1862–63), liked the area so much that at one point he suggested it be made the summer capital of India. He died at Dharamshala while on a tour there, on 20 November 1863, and lies buried at the St. John in the Wilderness at Forsyth Ganj, just below McLeod Ganj. His summer residence, Mortimer House, became part of the private estate of Lala Basheshar Nath of Lahore and was acquired by the Government of India to house the official residence of the Dalai Lama.
The twin towns of Forsyth Ganj and McLeod Ganj continued to grow steadily in the coming years, and by 1904 had become important centres of trade, commerce and official work of Kangra District. Much of the town was destroyed by the devastating 7.8 magnitude 1905 Kangra earthquake at 6:19 am 4 April 1905; close to 19,800 people were killed and thousands were injured in the Kangra area. The earthquake destroyed most buildings in Kangra, Dharamshala, and McLeod Ganj, including the Bhagsunath Temple. Thereafter, district headquarters were shifted to a lower spot, and the town waited another half century before anything significant transpired in its history.
In March 1959, Tenzin Gyatso, the 14th Dalai Lama, fled to India after the failed uprising in 1959 in Tibet against the Communist Party of China. The Indian Government offered him refuge in Dharamshala, where he set up the Government of Tibet in exile in 1960, while McLeod Ganj became his official residence and also home to several Buddhist monasteries and thousands of Tibetan refugees. Over the years, McLeod Ganj evolved into an important tourist and pilgrimage destination, and has since grown substantially in population.