In the meantime, the British were engaged in preventing the Gorkhas from over-running the whole of the northern frontier. The Anglo-Gorkha war broke out in 1814, which resulted in the defeat of the Gorkhas and subsequently led to the signing of the Sugauli Treaty in 1815. According to the treaty, Nepal had to cede all those territories which the Gorkhas had annexed from the Chogyal of Sikkim to the British East India Company (i.e., the area between Mechi River and Teesta River). In 1817, through the Treaty of Titalia, the British East India Company reinstated the Chogyal of Sikkim, restored all the tracts of land between the Mechi and the Teesta rivers to the Chogyal of Sikkim and guaranteed his sovereignty. In 1835, the hill of Darjeeling, including an enclave of , was given to the British East India Company by Sikkim.