Coolie labourer c. 1900 in Zhenjiang, China. The bamboo pole he leans upon was used to hoist and carry the bundle at his feet with the pole over his shoulder and the bundle leaning against his back. On the left side of the image, in the background, another man uses this same technique of bearing a heavy load.
Slavery in China has taken various forms throughout history. Slavery was repeatedly abolished as a legally-recognized institution, including in a 1909 law fully enacted in 1910, although the practice continued until at least 1949.
Slavery was established in China by at least the Shang dynasty, at which point it has been estimated that about 5 percent of the population was enslaved.
Qin Dynasty (221-206 BC)
Men sentenced to castration were turned into eunuch slaves of the Qin dynasty state to do forced labor, for projects like the Terracotta Army. The Qin government confiscated the property and enslaved the families of those who received castration as a punishment for rape.
Slaves were deprived of their rights and connections to their families.
Men punished with castration during the Han dynasty were also used as slave labor.
Deriving from earlier Legalist laws, the Han dynasty set in place rules that the property of and families of criminals doing three years of hard labor or sentenced to castration were to have their families seized and kept as property by the government.
In the year 17 C.E, the Emperor Wang Mang usurped the Chinese throne and instituted a series of sweeping reforms, including the abolition of slavery and radical land reform. After his assassination in 23 C.E., slavery was reinstituted.
During the Three Kingdoms period, a number of statuses intermediate between freedom and slavery developed, but none of them is thought to have exceeded 1 percent of the population.
A contract from the Tang dynasty that records the purchase of a 15 year-old slave for six bolts of plain silk and five Chinese coins.
Tang Law held that free people could not be enslaved, and slaves who were sold had to be previously held as slaves in order to be sold legally. A large amount of slave trading took place on Silk Road markets during this time; there are several examples of Sogdian slave girls being sold by Sogdian merchants to Chinese.
Chinese law segregated slaves and freemen into different classes, and slaves were classified as criminals. Only criminals and foreigners were allowed to be enslaved in China. Sexual relationships between foreign slaves and Chinese women were banned.
Tang army expeditions in Korea, Mongolia, Central Asia and India captured foreigners as slaves. After executing the men, Tang dynasty armies enslaved captive women. 
Persians were kidnapped by pirates and kept in captivity on Wan-an, Hainan island, before being sold. Samanids in Transoxania sold Turks to the Chinese.
Free Chinese could not be legally sold as slaves unless they willingly sold themselves. If they did not sell themselves, the person who sold them could be executed. However, all other peoples were subject to involuntary enslavement. Southern aboriginals constituted the largest number of slaves. Other peoples sold to Chinese included Turks, Persians, and Korean women, who were sought after by the wealthy. China suffered from shortages of women for marriage, which led to Korean women being sold in Chinese slave markets to compensate for this. The Chinese demand for young Korean slave girls as concubines created a lucrative market for pirates in Korean waters. Their captives were sold in Shandong, China. The Chinese Governor of Shandong banned the trade in 692.
A massive market in the trade of southern aboriginal slave girls also existed. Chinese officials denounced it and attempted to ban it, to no effect. Indian, Malay, and Black African slaves were also sold to the Chinese. Their skin was noted to be dark, their hair wavy or curly.
Tang law considered slaves to be chattel without rights as people. Free women could not marry male slaves.
The Song's warfare against northern and western neighbors produced many captives on both sides, but reforms were introduced to ease the transition from bondage to freedom.
The MongolYuan dynasty implemented a great expansion of slavery in China and restored harsher terms of service. However, because the Chinese were more integrated into the culture, such "slaves" often proved so invaluable they came to possess a great deal of power themselves, including slaves of their own motherboarder. During insurrections and slave revolts, such disloyalty often led to their property being targeted first, even before the Mongols' themselves. In 1253, the Franciscan monk William of Rubruck reported numerous Europeans slaves in China. He also described German prisoners who had been enslaved in iron mines.
Ming Dynasty (1368-1644)
Upon his conquest over the Yuan Dynasty in 1368, China's Hongwu Emperor establishes the Ming dynasty and would abolish all forms of slavery. However, in practice, slavery continued through the Ming dynasty.
The Javans sent 30,000 black slaves as tribute to the Ming Dynasty in 1381. When the Ming Dynasty crushed the Miao Rebellions in 1460, they castrated 1,565 Miao boys, which resulted in the deaths of 329 of them, they were then turned into eunuch slaves. This event occurred during the rule of the Zhengtong Emperor (Yingcong or Ying Tsung). Since 329 of the boys died, even more were needed to be castrated.
Later Ming rulers, as a way of limiting slavery because of their inability to prohibit it, passed a decree that limited the number of slaves that could be held per household and extracted a severe tax from slave owners.
Qing Dynasty (1644-1912)
The Qing Dynasty initially oversaw an expansion in slavery and states of bondage like the booi aha. They possessed about two million slaves upon their conquest of China. However, as the previous Chinese rulers before them, the Qing rulers soon saw the advantages of slowly phasing out slavery, gradually introducing reforms turning slaves and serfs into peasants. Laws passed in 1660 and 1681 forbade landowners from selling slaves with the land they farmed and prohibited physical abuse of slaves by landowners. The Kangxi Emperor freed all the Manchu's hereditary slaves in 1685. The Yongzheng Emperor's "Yongzheng emancipation" between 1723 and 1730 sought to free all slaves to strengthen the autocratic ruler through a kind of social leveling that created an undifferentiated class of free subjects under the throne, freeing the vast majority of slaves.
The end of slavery elsewhere following the British emancipation led to increasing demands for cheap Chinese laborers, known as "coolies". Mistreatment ranged from the near-slave conditions maintained by some crimps and traders in the mid-1800s in Hawaii and Cuba to the relatively dangerous tasks given to the Chinese during the construction of the Central Pacific Railroad in the 1860s.
Among his other reforms, Hong Xiuquan abolished slavery and prostitution in the territory under his control in the 1850s and '60s.
Torghut Mongols, Han Chinese, and Hui Chinese Muslims were the main victims of slave trading in Xinjiang.
Free Chinese, such as Han Chinese and Hui Chinese Muslims (tungans) were all categorized as merchants regardless of profession. The other portion of the Chinese population were military soldiers or Han Chinese or Hui enslaved to Turkestani begs.
A Manchu historian Ji Dachen claimed that the Qing dynasty sent slaves to Turpan to build the karez for the Lukchun King and that the slaves mixed with the Uyghurs of Turpan, calling them a "mixed breed".
Slave raiders from Khoqand did not distinguish between Hui Muslim and Han Chinese, enslaving any Chinese they could in Xinjiang.
Turkic Muslim slaves
Turkic Muslims were also enslaved to begs after wars with Khwajas and Khoqand.
The Qing dynasty procured 420 women and girl slaves, all of them Mongol to service Oirat Mongol bannermen stationed in Xinjiang in 1764.
Many Torghut Mongols boys and girls were sold to Central Asian markets or on the local Xinjiang market to native Turkestanis. Officials in Xinjiang engaged in this illegal trade, which was banned by the government.
Hui Chinese Muslim slaves
Chinese Muslim (Tungans) Sufis who were charged by the Qing dynasty government with practicing xiejiao (heterodox religion), were punished by exile to Xinjiang and being sold as slaves to other Muslims, such as the Sufi begs.
Under the "fundamental laws" of China, one section is titled "Wizards, Witches, and all Superstitions, prohibited." The Jiaqing Emperor in 1814 A.D. added a sixth clause in this section with reference to Christianity. It was modified in 1821 and printed in 1826 by the Daoguang Emperor. It sentenced Europeans to death for spreading Christianity among Han Chinese and Manchus (tartars). Christians who would not repent their conversion were sent to Muslim cities in Xinjiang, to be given as slaves to Muslim leaders and beys.
The clause stated: "People of the Western Ocean, [Europeans or Portuguese,] should they propagate in the country the religion of heaven's Lord, [name given to Christianity by the Romanists,] or clandestinely print books, or collect congregations to be preached to, and thereby deceive many people, or should any Tartars or Chinese, in their turn, propagate the doctrines and clandestinely give names, (as in baptism,) inflaming and misleading many, if proved by authentic testimony, the head or leader shall be sentenced to immediate death by strangulations : he who propagates the religion, inflaming and deceiving the people, if the number be not large, and no names be given, shall be sentenced to strangulation after a period of imprisonment. Those who are merely hearers or followers of the doctrine, if they will not repent and recant, shall be transported to the Mohammedan cities (in Turkistan) and given to be slaves to the beys and other powerful Mohammedans who are able to coerce them. . . . All civil and military officers who may fail to detect Europeans clandestinely residing in the country within their jurisdiction, and propagating their religion, thereby deceiving the multitude, shall be delivered over to the Supreme Board and be subjected to a court of inquiry."
Intermarriage Between Slaves
While free Chinese merchants generally did not engage in relationships with East Turkestani women, some of the Chinese male slaves belonging to begs, along with Green Standard soldiers, engaged in affairs with the East Turkestani women. Some Muslim owners had children with Chinese women slaves.
After being freed, many slaves such as Gilgitis in Xinjiang cities like Tashkurgan, Yarkand, and Karghallik, stayed rather than return Hunza in 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 Hunza 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. The Hunzas are Ismaili Muslims 
The Hunzas were tributaries and allies to China, acknowledging China as suzerain. When the Hunzas raided the Kirghiz, they sold Kirghiz slaves to Chinese.
Badakhshi merchants sold attractive Chitral girls in Yarkand, China, for 20-25 pounds sterling, and this trade was facillated by Chinese officials. Others from Kunjoot, Gilgit, and Kafiristan were also enslaved and sold in Yarkand. The girls were sold by their parents.
The Qianlong Emperor had banned slavery in Xinjiang in 1778 or 1779, but it continued along with the administration of the Begs. Most foreign slaves in Xinjiang were Shia Mountain Tajiks.
The Tajiks of Xinjiang practiced slavery, selling some of their own as a punishment. Submissive slaves were given wives and settled with the Tajiks. They were considered property and could be sold anytime. Their slaves came from numerous sources, enslaving Sunni captives such as Kirghiz in retaliation for Kirghiz slave raids, or from Kunjud, Gilgit, Chitral. The Tajiks also sold some slaves to Bukhara. The Sunnis called them Rafidites and did not consider them Muslim.
Shia Muslims were sold as slaves in Khotan. The Muslims in Xinjiang ignored Islamic rules, selling and buying Muslims as slaves. Due to the enslavement of Indian subjects to the British crown from Kashmir being sold in the Xinjiang slave markets, Sir George Macartney was sent to free them, in the process, he freed 2,000. In 1897, slavery was abolished in Xinjiang. Macartney bought many slaves and freed them, not only Indians, but others as well. Several Xinjiang officials were then prompted to take actions freeing more slaves after Macartney's visit.
Slavery as punishment
Slavery and castration were used as punishments against rebels.
Ma Jincheng (1864–1890), the grandson of Ma Hualong, was sentenced to castration and slavery in Kaifeng since Ma Hualong participated in the Dungan revolt (1862–1877) against the Qing dynasty.
This article incorporates text from Life among the Chinese: with characteristic sketches and incidents of missionary operations and prospects in China, by Robert Samuel Maclay, a publication from 1861 now in the public domain in the United States.
This article incorporates text from The Imperial and asiatic quarterly review and oriental and colonial record, by Oriental Institute (Woking, England), East India Association (London, England), a publication from 1892 now in the public domain in the United States.
This article incorporates text from Innermost Asia: travel & sport in the Pamirs, by Ralph Patteson Cobbold, a publication from 1900 now in the public domain in the United States.
This article incorporates text from The journal of the Royal Geographical Society of London, Volume 40, by Royal Geographical Society (Great Britain), a publication from 1870 now in the public domain in the United States.
This article incorporates text from Central Asia: from the Aryan to the Cossack, by James Hutton, a publication from 1875 now in the public domain in the United States.
This article incorporates text from Report of a mission to Yarkund in 1873, under command of Sir T. D. Forsyth: with historical and geographical information regarding the possessions of the ameer of Yarkund, by Sir Thomas Douglas Forsyth, a publication from 1875 now in the public domain in the United States.
This article incorporates text from In Tibet and Chinese Turkestan: being the record of three years' exploration, by Henry Hugh Peter Deasy, a publication from 1901 now in the public domain in the United States.
This article incorporates text from The marches of Hindustan: the record of a journey in Thibet, Trans-Himalayan India, Chinese Turkestan, Russian Turkestan and Persia, by David Fraser, a publication from 1907 now in the public domain in the United States.