Hunza was an independent principality for centuries. It was ruled by the Mirs of Hunza, who took the title of Thum.
From 1847 the Mir of Hunza gave nominal allegiance to China. This resulted from assistance given by Mir Ghazanfur Khan to China in suppressing a rebellion in Yarkand, following which China granted Hunza a jagir in Yarkand and paid the Mir a subsidy.
The Hunzas were tributaries and allies to China, acknowledging China as suzerain.  When the Hunzas raided the Kirghiz, they sold Kirghiz slaves to Chinese.
The Tajiks of Xinjiang sometimes enslaved the Gilgitis and Kunjutis, with whome they had constant war with
Many Gilgitis and Kunjuti were also enslaved in China After being freed due to the efforts of British authorities in China, many slaves such as Gilgitis in Xinjiang cities like Tashkurgan, Yarkand, and Karghallik, stayed rather than return to Gilgit. Most of these slaves were women who married local slave and non slave men and had children with them. Sometimes the women were married to their masters, other slaves, or free men who were not their masters. There were ten slave men to slave women married couples, and 15 master slave women couples, with several other non master free men married to slave women. Both slave and free Turki and Chinese men fathered children with Gilgit slave women. A free man, Khas Muhammad, was married with 2 children to a woman slave named Daulat, aged 24. A Gilgiti slave woman aged 26, Makhmal, was married to a Chinese slave man, Allah Vardi and had 3 children with him.
In the late 19th century Hunza became embroiled in the Great Game, the rivalry between Britain and Russia for control of the northern approaches to India. The British suspected Russian involvement "with the Rulers of the petty States on the northern boundary of Kashmir;" In 1888 the Russian Captain Bronislav Grombchevsky visited Hunza, and the following year the British Captain Francis Young husband visited Hunza to express British displeasure at Kanjuti raids in the Raskam. In 1891 the British mounted the Hunza-Nagar Campaign and gained control of Hunza and the neighbouring valley of Nagar. Hunza rulers claimed descent from Alexander the Great, and viewed only themselves and the leader of China as being the most important leaders in the world. The last independent ruler,Mir Safdar Khan, who ruled from 1886, escaped to China. His younger brother Mir Mohammad Nazim Khan was installed by the British as Mir in September 1892.
The British retained Hunza's status as a 'princely state' until 1947.