Ethnic issues in China arise from Chinese history, nationalism, and other factors. They have driven historical movements such as the Red Turban Rebellion (which targeted the Mongol leadership of the Yuan Dynasty) and the Xinhai Revolution, which overthrew the Manchu Qing Dynasty. Ethnic tensions have led to incidents in the country such as the July 2009 Ürümqi riots.
China is a largely-homogenous society; over 90 percent of its population has historically been Han Chinese. Some of the country's ethnic groups are distinguishable by physical appearance and relatively-low intermarriage rates. Others have married Han Chinese and resemble them. A growing number of ethnic minorities are fluent at a native level in Mandarin Chinese. Children sometimes receive ethnic-minority status at birth if one of their parents belongs to an ethnic minority, even if their ancestry is predominantly Han Chinese. Pockets of immigrants and foreign residents exist in some cities.
A 100-day crackdown on illegal foreigners in Beijing began in May 2012, with Beijing residents wary of foreign nationals due to recent crimes. China Central Television host Yang Rui said, controversially, that "foreign trash" should be cleaned out of the capital. 
Racial discrimination by the ruling Han Chinese in imperial China has been documented in historical texts such as Yan Shigu's commentary on the Book of Han, in whcich the Wusun people were called "barbarians who have green eyes and red hair" and compared to macaques.
Some ethnic conflicts resulted in genocides. During the 350 AD Wei–Jie war, the Han Chinese leader Ran Min massacred non-Chinese Wu Hu in retaliation for abuses of the Chinese population; the Jie people were particularly affected. Rebels slaughtered Arab and Persian merchants in the Yangzhou massacre (760). According to Arab historian Abu Zayd Hasan of Siraf, the rebel Huang Chao's army killed Arab, Jewish, Christian, and Parsi merchants in the Guangzhou massacre when he captured Guang Prefecture. Arabs and Persians living in Quanzhou were massacred in the Ispah rebellion.
Widespread violence against the Manchu people by Han Chinese rebels occurred during the Xinhai Revolution, most notably in Xi'an (where the Manchu quarter's population—20,000—was killed) and Wuhan (where 10,000 Manchus were killed).[not in citation given] Manchus were seen as uncivilized and lacking culture, adopting Han Chinese and Tibetan culture instead. According to 20th-century social and cultural critic Lu Xun, "Throughout the ages, Chinese have had only two ways of looking at foreigners, up to them as superior beings or down on them as wild animals."
The Mongols divided groups into a four-class caste system during the Yuan dynasty. Merchants and non-Mongol overseers were usually immigrants or local ethnic groups: Turkestani and Persian Muslims and Christians. Foreigners from outside the Mongol Empire, such as the Polo family, were welcomed.
Despite the Muslims' high position, the Yuan Mongols discriminated against them: restricting halal slaughter and other Islamic practices, such as circumcision (and kosher butchering for Jews). Genghis Khan called Muslims "slaves". Muslim generals eventually joined the Han Chinese in rebelling against the Mongols. Ming dynasty founder Zhu Yuanzhang had Muslim generals (including Lan Yu) who rebelled against the Mongols and defeated them in battle. Semu-caste Muslims revolted against the Yuan dynasty in the Ispah rebellion, although the rebellion was crushed and the Muslims massacred by Yuan commander Chen Youding. Uyghur leader Sabit Damulla Abdulbaki said about the Han Chinese and Tungans (Hui Muslims):
The Tungans, more than the Han, are the enemy of our people. Today our people are already free from the oppression of the Han, but still continue under Tungan subjugation. We must still fear the Han, but cannot fear the Tungans also. The reason we must be careful to guard against the Tungans, we must intensely oppose, cannot afford to be polite. Since the Tungans have compelled us, we must be this way. Yellow Han people have not the slightest thing to do with Eastern Turkestan. Black Tungans also do not have this connection. Eastern Turkestan belongs to the people of Eastern Turkestan. There is no need for foreigners to come be our fathers and mothers ... From now on we do not need to use foreigners language, or their names, their customs, habits, attitudes, written language, etc. We must also overthrow and drive foreigners from our boundaries forever. The colors yellow and black are foul. They have dirtied our land for too long. So now it is absolutely necessary to clean out this filth. Take down the yellow and black barbarians! Long live Eastern Turkestan!"
An American telegram reported that Uyghur groups in parts of Xinjiang demanded the expulsion of White Russians and Han Chinese from Xinjiang during the Ili Rebellion. The Uyghurs reportedly said, "We freed ourselves from the yellow men, now we must destroy the white". According to the telegram, "Serious native attacks on people of other races frequent. White Russians in terror of uprising."
Tensions erupted between Muslim sects, ethnic groups, the Tibetans and Han Chinese during the late 19th century near Qinghai. According to volume eight of the Encyclopædia of Religion and Ethics, the Muslim Dungan and Panthay revolts were ignited by racial antagonism and class warfare.
Anti-Japanese sentiment primarily stems from Japanese war crimes committed during the Second Sino-Japanese War. History-textbook revisionism in Japan and the denial (or whitewashing) of events such as the Nanking Massacre by right-wing Japanese groups has continued to inflame anti-Japanese feeling in China. It has been alleged that anti-Japanese sentiment is also partially the result of political manipulation by the Communist Party. According to a BBC report, anti-Japanese demonstrations received tacit approval from Chinese authorities (although Chinese ambassador to Japan Wang Yi said that the Chinese government does not condone such protests).
We have to conquer our own country and purify it of all infidels. Then, we should conquer the infidels’ countries and spread Islam. The infidels who are usurping our countries have announced war against Islam and Muslims, forcing Muslims to abandon Islam and change their beliefs.
In Bayanday there is a brick factory,
it had been built by the Chinese.
If the Chinese are killed by soldiers,
the Tungans take over the plundering.
A Uyghur would reportedly not enter a Hui mosque, and Hui and Han households were built together in a town; Uyghurs would live farther away. Uyghurs have been known to view Hui Muslims from other provinces of China as hostile and threatening. Mixed Han and Uyghur children are known as erzhuanzi (二转子); Uyghurs call them piryotki, and shun them.
The Chinese government and individual Han Chinese citizens have been accused of discrimination against the Uyghur minority. This was a reported cause of the July 2009 Ürümqi riots, which occurred largely along racial lines. A People's Daily essay referred to the events as "so-called racial conflict", and several Western media sources called them "race riots". Unofficial Chinese policy reportedly denies passports to Uyghurs until they reach retirement age, especially if they intend to leave the country for the pilgrimage to Mecca.
Tensions between Hui and Uyghurs arose because Qing and Republican Chinese authorities used Hui troops and officials to dominate the Uyghurs and suppress Uyghur revolts. The Uyghur population grew by 1.7 percent in Xinjiang between 1940 and 1982, and the Hui population increased by 4.4 percent. Tensions have increased between Uyghur and Hui Muslims due to the population-growth disparity. The massacre of Uyghurs by Ma Zhongying's Hui troops in the Battle of Kashgar (1934) caused unease as more Hui moved into the region from other parts of China.
Some Hui criticize Uyghur separatism. According to Dru C. Gladney, the Hui "don't tend to get too involved in international Islamic conflict. They don't want to be branded as radical Muslims." Hui and Uyghurs live and worship separately.
Han and Hui intermarry more than Uyghurs and Hui do, despite the latter's shared religion. Some Uyghurs believe that a marriage to a Hui is more likely to end in divorce.
The Sibe tend to believe negative stereotypes of Uyghurs and identify with the Han.[not in citation given] According to David Eimer, one Han person had a negative view of Uyghurs but had a positive opinion of Tajiks in Tashkurgan.
Yengisar (يېڭىسار, Йеңисар) is known for the manufacture of Uyghur handcrafted knives—yingjisha (英吉沙刀 or 英吉沙小刀) in Chinese. Although the wearing of knives by Uyghur men (indicating the wearer's masculinity) is a significant part of Uyghur culture. it is seen as an aggressive gesture by others. The Uyghur word for knife is pichaq (پىچاق, пичақ), and the plural is pichaqchiliq (پىچاقچىلىقى, пичақчилиқ). Limitations were placed on knife vending due to terrorism and violent assaults where they were utilized. Robberies and assaults committed by groups of Uighurs, including children sold to (or kidnapped by) gangs, have increased tensions. China has been working on multilateral anti-terrorism since the September 11 attacks and, according to the United Nations and the U.S. Department of State, some Uyghur separatist movements have been identified as terrorist groups..
This section is missing information about racism against Tibetans by Han Chinese and other ethnic groups.(August 2017)
Many residents of the frontier districts of Sichuan and other Tibetan areas in China are of Han-Tibetan ethnicity, and are looked down on by Tibetans.[needs update] Tibetan Muslims, known as Kache in Tibetan, have lived peacefully with Tibetan Buddhists for over a thousand years because Buddhists are prohibited by their religion from killing animals but require meat to survive in their mountainous climate. However, Tibetans clash with the Hui (known as Kyangsha in Tibetan). Tibetans and Mongols refused to allow other ethnic groups (such as the Kazakhs) to participate in a ritual ceremony in Qinghai until Muslim general Ma Bufang reformed the practice.
Most Muslims in Tibet are Hui. Although hostility between Tibetans and Muslims stems from the Muslim warlord Ma Bufang's rule in Qinghai (the Ngolok rebellions (1917–49) and the Sino-Tibetan War), in 1949 the Communists ended violence between Tibetans and Muslims. However, recent Tibetan-Muslim violence occurred. Riots broke out between Muslims and Tibetans over a bone in soups and the price of balloons; Tibetans accused Muslims of being cannibals who cooked humans, attacking Muslim restaurants. Fires set by Tibetans burned the apartments and shops of Muslims, and Muslims stopped wearing their traditional headwear and began to pray in secret. Chinese-speaking Hui also have problems with the Tibetan Hui (the Tibetan-speaking Kache Muslim minority).
The main mosque in Lhasa was burned down by Tibetans, and Hui Muslims were assaulted by rioters in the 2008 Tibetan unrest. Tibetan exiles and foreign scholars overlook sectarian violence between Tibetan Buddhists and Muslims. Most Tibetans viewed the wars against Iraq and Afghanistan after the September 11 attacks positively, and anti-Muslim attitudes resulted in boycotts of Muslim-owned businesses. Some Tibetan Buddhists believe that Muslims cremate their imams and use the ashes to convert Tibetans to Islam by making Tibetans inhale the ashes, although they frequently oppose proposed Muslim cemeteries.[need quotation to verify] Since the Chinese government supports the Hui Muslims, Tibetans attack the Hui to indicate anti-government sentiment and due to the background of hostility since Ma Bufang's rule; they resent perceived Hui economic domination.
In 1936, after Sheng Shicai expelled 20,000 Kazakhs from Xinjiang to Qinghai, Hui troops led by Ma Bufang]] reduced the number of Kazakhs to 135. Over 7,000 Kazakhs fled northern Xinjiang to the Tibetan Qinghai plateau region (via Gansu), causing unrest. Ma Bufang relegated the Kazakhs to pastureland in Qinghai, but the Hui, Tibetans and Kazakhs in the region continued to clash.
In northern Tibet, Kazakhs clashed with Tibetan soldiers before being sent to Ladakh. Tibetan troops robbed and killed Kazakhs at Chamdo, 400 miles (640 km) east of Lhasa, when the Kazakhs entered Tibet. In 1934, 1935 and 1936-1938, an estimated 18,000 Kazakhs entered Gansu and Qinghai. In 2017, the Dalai Lama compared the peacefulness of China's Muslims unfavorably to that of their Indian counterparts.
Hostility to foreigners by high-ranking Chinese Muslim officers was sparked by foreign arrogance about Chinese affairs; status and wealth were contributing factors. A Hui soldier from the 36th Division called Swedish explorer Sven Hedin a "foreign devil", and Tungans were reportedly "strongly anti-Japanese". During the 1930s, a White Russian driver for Nazi agent Georg Vasel in Xinjiang was afraid to meet Hui general Ma Zhongying, saying: "You know how the Tungans hate the Russians." Vasel passed the Russian driver off as a German.
A Chinese Muslim general encountered by writer Peter Fleming thought that his visitor was a foreign "barbarian" until he learned that Fleming's outlook was Chinese. Fleming saw a Uyghur grovel at the general's feet, and other Uighurs were treated contemptuously by his soldiers. Racial slurs were allegedly used by the Chinese Muslim troops against Uyghurs. Ma Qi's Muslim forces ravaged the Labrang Monastery over an eight-year period.
According to historian Frank Dikötter,
A common historical response to serious threats directed towards a symbolic universe is "nihilation", or the conceptual liquidation of everything inconsistent with official doctrine. Foreigners were labelled "barbarians" or "devils", to be conceptually eliminated. The official rhetoric reduced the Westerner to a devil, a ghost, an evil and unreal goblin hovering on the border of humanity. Many texts of the first half of the nineteenth century referred to the English as "foreign devils" (yangguizi), "devil slaves" (guinu), "barbarian devils" (fangui), "island barbarians" (daoyi), "blue-eyed barbarian slaves" (biyan yinu), or "red-haired barbarians" (hongmaofan).
Chinese orthography provides opportunities to write ethnic insults logographically. Some Chinese characters used to transcribe the names of non-Chinese peoples were graphically-pejorative ethnic slurs, where the insult was not the Chinese word but the character used to write it. For example, the name of the Yao people was transcribed as 猺, a character which also means "jackal" and is written with the dog radical 犭. This name for the Yao, developed by 11th-century Song dynasty authors, has been replaced twice in 20th-century language reforms: with the invented character yao 傜 (with the human radical 亻) and with yao 瑤 (with the jade radical 玉), which can also mean "precious jade". Although the characters have the same pronunciation, they have different radicals (which convey different meanings).
A group of Kazakhs, originally numbering over 20000 people when expelled from Sinkiang by Sheng Shih-ts'ai in 1936, was reduced, after repeated massacres by their Chinese coreligionists under Ma Pu-fang, to a scattered 135 people.
Even now, some Guangzhou residents might admit using the generic and derogatory term "hei gui" or "ghost" to refer to Africans in the community.