The construction of Kashan's fortifications is attributed to Zobeida, Caliph Harun al-Rashid's wife, who also provided financial assistance for many similar structures in other cities of the Islamic world. Malek Shah Seljuk reinforced Kashan's ramparts and also built the Jalali Fortress in the western part of | the town. Some old chronicles indicate that there also used to be a moat in front of the ramparts, but the precise evidence of its existence belongs to a much later date. Together, the fortifications allowed for the town's impregnability from attack by any military force. For example, in 1141, Kashan withstood a severe three-month siege, while many unfortified towns and villages in its vicinity were ruined.
The same result occurred in 1198 when Kashan was besieged by KharazmShahs's troops. After that, the fortifications were repaired and extended to encompass the districts that emerged after the initial ramparts had been laid out. Because the Jalali Fortress was often occupied by the mutineers, Shah Ismail Safavid ordered its destruction; however, this order was never obeyed. On the contrary, the site was further repaired, especially during the revolt of Mohammad Khan Turkman, who occupied the Jalali Fortress and sacked the neighboring towns and villages for twelve years. One of their sorties even reached Esfahan, where they killed Mahd Oliya, mother of Shah Abbas I. It is said that, at that time, the walls were 6 m thick and 4 m high. The peaceful reign of Shah Abbas I led to the partial destruction of the fortifications, except for the outer ramparts, towers, and Safavid-period icehouses - practically the same as what can be seen today.
Afghan invaders further ruined the structures, this time purposely. In later periods, the ramparts were restored to some extent. More walls were also added in such a way that, if necessary, the town could be defended house by house. The fortifications suffered greatly in the earthquake of 1778 but were repaired soon afterward. Reinforced with a moat, they served well in repulsing the attacks during the early Qajar period, when Kashan was constantly threatened by enemies.
The ramparts were repaired by Abdolrezaq Khan Kashi, the town's governor, who added two gates to the existing five gates, each topped with a watchtower. Of all the gates, Dowlat Gate (where the municipality is located today) was the most important. Its significance was also enhanced by a complex of splendid buildings, which included a large bazaar and a caravanserai with a handsome portal. These structures were demolished in modern times when the town was expanded and modern alleys were laid out. The last time that Kashan's fortifications were used was during the revolt headed by Naeb Hossein Kashi and his sons.