As early as the 1510s, Tbilisi, Kartli and Kakheti, were made vassal territories of Safavid Iran. In 1522, Tbilisi was garrisoned for the first time by a large Safavid force. Following the death of king ("shah") Ismail I (r. 1501-1524), king David X of Kartli expelled the Iranians. During this period, many parts of Tbilisi were reconstructed and rebuilt. The four campaigns of king Tahmasp I (r. 1524-1576) resulted in the reoccupation of Kartli and Kakheti, and a Safavid force was permanently stationed in Tbilisi from 1551 onwards. With the 1555 Treaty of Amasya, and more firmly from 1614 to 1747, with brief intermissions, Tbilisi was an important city under Iranian rule, and it functioned as a seat of the Iranian vassal kings of Kartli whom the shah conferred with the title of vali. A wall was built around the city in 1675 by Shah Suleiman I. Under the later rules of Teimuraz II and Erekle II, Tbilisi became a vibrant political and cultural center free of foreign rule, but the city was captured and devastated in 1795 by the Iranian Qajar ruler Agha Mohammad Khan, who sought to re-establish Iran's traditional suzerainty over the region.