The Dungans crossed the Russian border first as defeated Muslim rebels from Kansu and Shensi provinces from 1877 to 1878 and then as settlers from the Ili region from 1881 to 1884. Their first migration was the direct outcome of the defeat of the Muslim rebellions in northwest China (1862—1878). After the fall of Kashgar and the final victory by the Manchu in Xinjiang, three groups of Muslim rebels crossed the Tianshan into Russia during the exceptionally severe winter of 1877. Many of these desperate refugees, especially old people and children, perished during this crossing. Both during the crossing and after their arrival, they were assisted by the Russians, Kyrgyz, and Kazakhs. General Kolpakovsky, the governor of Semirechenskaia Oblast, was instructed to accept these refugees and to give them land. One of the main reasons for this was that Russia had recently occupied the area where Kyrgyz and Kazakhs lived and did not want to alienate these Muslim minorities by refusing to help the Muslims from China. Of the three groups, about 1,000 settled near Osh, 1,130 settled near Przheval'sk, and 3,314 near Tokmak. Their descendants still reside in these settlements.
The second migration of Muslims from China occurred after the signing of the Treaty of St. Petersburg on 12 February 1881. The Ili region was occupied by Russian troops in 1871 and was under the jurisdiction of the Russian governor-general of Turkestan until 1881. According to the treaty between China and Russia, Russia was to return Kul'ja to China with the provision that a consulate should be established there, and Russia was to recognize Chinese rule over Kashgaria. The population of the Ili region could now make a choice: either they could stay under the much-hated, oppressive Manchu rule or leave behind the work of generations—houses, fields, and vegetable gardens—and move to Russia.
The Russian government was in favor of this migration. From the political point of view, the Muslims were bitter enemies of the Manchu, which would make them trustworthy and loyal Russian subjects. As experienced farmers, they were welcomed in the Semirechie area. On 20 June 1881 Kaufmann, the governor-general of Turkestan, sent a telegram giving the Muslims permission to send representatives to select locations for settlement along the Chilik River and the right bank of the Ili River. Eventually a small village called Sokuluk (located 30 kilometers west of Frunze, the present capital of the Kyrgyz Republic) was selected. The relocation took place between 1881 and 1884. The official number of Chinese Muslim settlers from Kul'ja is estimated at 4,682 people in all. Unlike the first migration, which was a headlong flight of desperate people chased by an enemy as they crossed the formidable Tianshan, the second migration occurred in times of peace and good weather. Those who intended to move had time to gather in the harvest, sell their houses and some of their possessions, and purchase provisions, horses, and carts for the long journey. Another difference was that, whereas the refugees in the first migration fled to and settled in the Semirechie area in three compact groups, the settlers from the Ili region came in small parties and settled all along the 1,000-kilometer route that stretched from the Chinese border to the appointed final destination of Sokuluk.
The main differences between the Dungans and the Chinese Muslims are that the Dungans have a higher standard of living than do the Chinese Muslims, and the Chinese Muslims are much more religious than the Dungans. Because the first Dungans arrived in Russia either because of the Muslim revolts against Manchu rule or the ill treatment of Muslims by Chinese and Manchu in general, the present-day Dungans are nationalistic and insist that they are not "Chinese Muslims" but "Dungans" and that they speak the Kansu Dungan dialect and the Shensi Dungan dialect, which are related to but differ somewhat from the Shensi and Kansu dialects in China. In addition, they refer to their food as "Dungan" food and to the stories they brought from China as "Dungan" stories. They also have the tendency to refer to all the Muslims in the world as "Dungans."