Hami is a modern city named after the Chinese name for the wider province, a disputed region claimed by various states throughout history, and its historic capital, Qocho, about 325 km to the west.

During the Later Han dynasty, Hami repeatedly changed hands between the Chinese and Xiongnu who both wanted to control this fertile and strategic oasis.
Several times the Han set up military agricultural colonies to feed their troops and supply trade caravans.
It was especially noted for its melons, raisins and wine.

"The region of Yiwu [Hami] is favourable for the five types of grain [rice, two kinds of millet, wheat and beans], mulberry trees, hemp, and grapes.
Further north is Liuzhong [Lukchun].
All these places are fertile.
This is why the Han have constantly struggled with the Xiongnu over Jushi [Turfan/Jimasa] and Yiwu [Hamich], for the control of the Western Regions."

The decline of the Xiongnu and the Han dynasty led to relative stability and peace for Hami and the surrounding area.
However, in 456, the Northern Wei dynasty occupied the Hami region.
Based here, they launched raids against the Rouran Khagante.
After the decline of the Northern Wei dynasty around the 6th century,  the First Turkic Khaganate assumed control of the region.
Hami was then tossed around between the western and eastern branches of the khaganate.

Xuanzang visited the oasis town, famous for its melons, the first of a string of oases supplied by the Tian Shan Mountains.
This water had been preserved in underground wells and channels since time immemorial.
The town had long been inhabited by a Chinese military colony.
During the early Tang dynasty and reaching into the Sui dynasty, the Chinese colony had accepted Turkic rule.
Xuanzang stayed at a monastery inhabited at the time by three Chinese monks.

The Tang Dynasty asserted control over the region and occupied Hami in the 7th century.
The Tibetan Empire and the Tang vied for control of the region until the Chinese were repelled in 851.
After the collapse of the Uyghur empire, a group of Uyghurs migrated to the Hami region and ushered in an era of linguistic and cultural change of the local population.
The Mongols conquered this region during the Yuan Dynasty.
Later Gunashiri, a descendant of Chagatai Khan, founded his own small state called Qara Del in Kumul or Hami, which accepted Ming supremacy in the early 15th century, but was conquered by another branch of Mongols later on.

The Ming Dynasty established this region as Kumul Hami in 1404 after the Mongol kingdom Qara Del accepted its supremacy.
But it was later controlled by Oirat Mongols.
Hami officially accepted and converted to Islam in 1513.
Since the 18th century, Kumul became the center of the Kumul Khanate, a semi-autonomous vassal state within the Qing Empire and the Republic of China as part of Xinjiang.
The last ruler of the khanate was Maqsud Shah.

A traveler in 1888 gave the following description of the city:
""The kingdom of Ha-mi contains a great number of villages and hamlets; but it has, properly, only one city, which is its capital, and has the same name.
It is surrounded by lofty wall, which are half a league in circumference, and has two gates, one of which fronts the east, and the other the west.
These gates are exceedingly beautiful, and make a fine appearance at a distance.
The streets are straight, and well laid out; but the houses (which contain only a ground-floor, and which are almost all constructed of earth) make very little shew: however, as this city enjoys a serene sky, and is situated in a beautiful plain, watered by a river, and surrounded by mountains which shelter it from the north winds, it is a most agreeable and delightful residence.
On whatever side one approaches it, gardens may be seen, which contain everything that a fertile and cultivated soil can produce in the mildest climates.
All the surrounding fields are enchanting; but they do not extend far; for on several sides they terminate in dry plains, where a number of beautiful horses are fed, and a species of excellent sheep, which have large flat
Hami is a modern city named after the Chinese name for the wider province, a disputed region claimed by various states throughout history, and its historic capital, Qocho, about 325 km to the west.
During the Later Han dynasty, Hami repeatedly changed hands between the Chinese and Xiongnu who both wanted to control this fertile and strategic oasis. Several times the Han set up military agricultural colonies to feed their troops and supply trade caravans. It was especially noted for its melons, raisins and wine.
"The region of Yiwu [Hami] is favourable for the five types of grain [rice, two kinds of millet, wheat and beans], mulberry trees, hemp, and grapes. Further north is Liuzhong [Lukchun]. All these places are fertile. This is why the Han have constantly struggled with the Xiongnu over Jushi [Turfan/Jimasa] and Yiwu [Hamich], for the control of the Western Regions."
The decline of the Xiongnu and the Han dynasty led to relative stability and peace for Hami and the surrounding area. However, in 456, the Northern Wei dynasty occupied the Hami region. Based here, they launched raids against the Rouran Khagante. After the decline of the Northern Wei dynasty around the 6th century,  the First Turkic Khaganate assumed control of the region. Hami was then tossed around between the western and eastern branches of the khaganate.
Xuanzang visited the oasis town, famous for its melons, the first of a string of oases supplied by the Tian Shan Mountains. This water had been preserved in underground wells and channels since time immemorial. The town had long been inhabited by a Chinese military colony. During the early Tang dynasty and reaching into the Sui dynasty, the Chinese colony had accepted Turkic rule. Xuanzang stayed at a monastery inhabited at the time by three Chinese monks.
The Tang Dynasty asserted control over the region and occupied Hami in the 7th century. The Tibetan Empire and the Tang vied for control of the region until the Chinese were repelled in 851. After the collapse of the Uyghur empire, a group of Uyghurs migrated to the Hami region and ushered in an era of linguistic and cultural change of the local population. The Mongols conquered this region during the Yuan Dynasty. Later Gunashiri, a descendant of Chagatai Khan, founded his own small state called Qara Del in Kumul or Hami, which accepted Ming supremacy in the early 15th century, but was conquered by another branch of Mongols later on.
The Ming Dynasty established this region as Kumul Hami in 1404 after the Mongol kingdom Qara Del accepted its supremacy. But it was later controlled by Oirat Mongols. Hami officially accepted and converted to Islam in 1513. Since the 18th century, Kumul became the center of the Kumul Khanate, a semi-autonomous vassal state within the Qing Empire and the Republic of China as part of Xinjiang. The last ruler of the khanate was Maqsud Shah.
A traveler in 1888 gave the following description of the city:
""The kingdom of Ha-mi contains a great number of villages and hamlets; but it has, properly, only one city, which is its capital, and has the same name. It is surrounded by lofty wall, which are half a league in circumference, and has two gates, one of which fronts the east, and the other the west. These gates are exceedingly beautiful, and make a fine appearance at a distance. The streets are straight, and well laid out; but the houses (which contain only a ground-floor, and which are almost all constructed of earth) make very little shew: however, as this city enjoys a serene sky, and is situated in a beautiful plain, watered by a river, and surrounded by mountains which shelter it from the north winds, it is a most agreeable and delightful residence. On whatever side one approaches it, gardens may be seen, which contain everything that a fertile and cultivated soil can produce in the mildest climates. All the surrounding fields are enchanting; but they do not extend far; for on several sides they terminate in dry plains, where a number of beautiful horses are fed, and a species of excellent sheep, which have large flat 
Hami