Mughal rule in Himachal Pradesh
The small hill kingdoms enjoyed independence until Muslim invasions in northern India. Provinces of the foothills were highly devastated by the Muslim invaders from timebeing. During the 10th century Mahmud Ghaznavi conquered Kangra. Timur and Sikander Lodi also captured several forts and fought many battles. Later, due to internal conflicts within the Mughal dynasty the rulers of the hill provinces took complete advantage. Kangra regained its independence under Maharaja Sansar Chand who ruled for nearly 50 years. He was one of the most powerful administrators of the region. After he took the formal possession of Kangra fort, Maharaja Sansar Chand began to expand his territory. The states of Chamba, Suket, Mandi, Bilaspur, Guler, Jaswan, Siba and Datarpur came under the direct control of Maharaja Sansar Chand.
Anglo gorkha war
The Gorkhas (martial tribe) came to power in Nepal in 1768. The gorkhas consolidated their military power and expanded their territory. Over a period of time the Gorkhas annexed Sirmour and Shimla hill states. Under the leadership of Amar Singh Thapa, Gorkhas laid their siege to Kangra. They defeated Maharaja Sansar Chand who was the ruler of Kangra, in 1806 with the help of hill chiefs. However, Gorkhas were not able to capture Kangra fort which came under the direct control of Maharaja Ranjeet Singh in 1809. After the defeat the Gorkhas began to expand towards the southern provinces. This lead in the Anglo-Gorkha war. They came into direct conflict with the British along the tarai belt after which the British expelled them. The British slowly emerged as the paramount powers in this conflict.
Anglo Sikh war
After the Anglo-Gorkha war the common border shared by the British domain and Punjab became extremely sensitive. Both the Sikhs and British wanted to avoid a direct conflict, but after the death of Ranjit Singh, the Khalsa army fought numerous wars with the British. In 1845 when the Sikhs invaded the British territory by crossing the Satluj river, the rulers of many hill provinces sided with the British. Many of these hill state rulers entered into the secret communication with the British. After the first Anglo-sikh war, the British didn't restore the hill territory departed by the Sikhs to their original owners.