The history of the area that now constitutes Himachal Pradesh dates back to the time when the Indus valley civilisation flourished between 2250 and 1750 BCE. Tribes such as the Koilis, Halis, Dagis, Dhaugris, Dasa, Khasas, Kinnars and Kirats inhabited the region from pre-historic era. During the Vedic period, several small republics known as "Janapada" existed which were later conquered by the Gupta Empire. After a brief period of supremacy by King Harshavardhana, the region was de novo divided into several local powers headed by chieftains, including some Rajput principalities. These kingdoms that enjoyed a large degree of independence and were invaded by Delhi Sultanate a number of times. Mahmud Ghaznavi conquered Kangra at the beginning of the 10th century. Timur and Sikander Lodi also marched through the lower hills of the state and captured a number of forts and fought many battles. Several hill states acknowledged Mughal suzerainty and paid regular tribute to the Mughals.
The Ghurkhas, a martial tribe came in to power in Nepal in the year 1768. They consolidated their military power and began to expand their territory. Gradually the Gorkhas annexed Sirmour and Shimla. With the leadership of Amar Singh Thapa, Gorkhas laid siege to Kangra. They managed to defeat Sansar Chand Katoch, the ruler of Kangra, in 1806 with the help of many provincial chiefs. However Gorkhas could not capture Kangra fort which came under Maharaja Ranjeet Singh in 1809. After the defeat the Gorkhas began to expand towards the south of the state. However, Raja Ram Singh, Raja of Siba State managed to capture the fort of Siba from the remnants of Lahore Durbar in Samvat 1846, during the First Anglo-Sikh War. They came into direct conflict with the British along the tarai belt after which the British expelled them from the provinces of the Sutlej. The British gradually emerged as the paramount power. In the revolt of 1857, or first Indian war of independence, arising from a number of grievances against the British, the people of the hill states were not as politically active as were those in other parts of the country. They and their rulers, with the exception of Bushahr, remained more or less inactive. Some, including the rulers of Chamba, Bilaspur, Bhagal and Dhami, rendered help to the British government during the revolt.