The land of Sikkim was an independent state during the early 17th century. Its boundaries extended as far as eastern Nepal. The king of Nepal, Prithvi Narayan Shah conquered Sikkim. As Darjeeling was a part of Sikkim in those days, Prithvi Narayan Shah added Darjeeling to the Nepali kingdom. At the end of the 1813, the British East India Company declared a war against Nepal. Under the leadership of General Ochterlony the British gained victory over Nepal. A treaty was signed at the close of 1816 in a place called Sugauli. It was decided that Nepal surrender 4,000 sq. miles of its territory to the British. On the 10th of February 1817, another treaty was signed called the treaty of Titaliya. According to this treaty the area of Darjeeling was handed over to the Raja of Sikkim.