 Khoy city was fortified at various times in its history, most recently by the Qajar dynasty in the nineteenth century.After the death of Nadir Shah Afshar in 1747, Khoy and its immediate surroundings broke away from central government of Iran like several other regions of Iran, including what is now Georgia and some of the northern Caucasian Khanates comprising the northwestern territories of Iran.Khoy became the centre of the newly established Khanate of Khoy (1747–1813) which was loyal to the central government only when it was powerful (like during Karim Khan's reign), and autonomous when the central role was weak.