Shabdrung Ngawang Namgyal, the Tibetan lama and military leader, found Bhutan fragmented in small fiefdoms in the early 17th century that constantly used to fight with each other. He unified all of them under one flag and built a network of fortresses known as dzong to protect Bhutan against Tibetan attacks and intermittent forays. These dzong were impregnable. Namgyal also developed and publicized a code of law for the local lords so that the centralized government can control them easily. One can still see and visit many of these dzong in Bhutan. Namgyal died in 1651 and Bhutan immediately fell into anarchy once again. However, Bhutanese managed to successfully thwart the Tibetan attacks in 1710 and in 1730, when Mongols aided them too. In 1759, both the parties finally signed a peace agreement.
After the truce from Tibetans, Bhutanese invaded a kingdom to its south known as Cooch Behar and occupied it. The kingdom sought help from the British East India Company in and promptly got help from them. In 1772, British East India Company helped Cooch Behar to throw the Bhutanese out and later attack Bhutan in 1774. Bhutan then signed a peace treaty with the East India Company by agreeing to retreat to its pre-1730 borders. Yet, it was not the end of the border skirmishes between Bhutan and British, which continued for the next hundred years. In 1864-65, once again the Duar War was fought between the British and the Bhutan to gain the control over the Bengal Duars.
Bhutan lost the war and the Treaty of Sinchula was signed between British India and Bhutan. According to this treaty, the United Kingdom of Great Britain and Ireland would get the Duars and they would pay Bhutan a rent of Rs 50,000 in exchange. This treaty was the one that actually brought peace and ended all hostilities between British India and Bhutan. 1870s was a decade of Civil War in Bhutan that resulted from the power struggles between the rival valleys of Paro and Trongsa. Finally, the Ponlop or Governor of Trongsa known as Ugyen Wangchuck gained the ascendancy and defeated his political enemies. Wangchuck based his power base in Central Bhutan and united the country during the period of 1882-85 by crushing the rebellions and successfully stopping the turbulence caused by several civil wars during this period.