Bai Yanhu was a commander of a battalion of Hui Muslim forces from Shaanxi during the Dungan Revolt. After being pushed out of Shaanxi by Qing forces under the command of Zuo Zongtang, he fled to the Jahriyya stronghold of Jinjipu (near modern-day Wuzhong, Ningxia). After the surrender of Jinjipu, Bai and his followers fled to Hezhou (today's Linxia). After the surrender of Hezhou, he fled to Xining. In 1873, Bai decided to leave Xining and flee to Xinjiang. The exact number of his followers at this time is unknown but it was likely several thousand, and some sources claim that it was between thirteen and thirty-five thousand. After entering Xinjiang, troops led by Bai managed to take control of Hami, but they abandoned the city shortly thereafter, fleeing from the approaching Qing army. In late 1873, they entered territory controlled by Yaqub Beg. Bai agreed to submit to Yaqub Beg and his followers were permitted to live in the area around Urumqi and Manas. When Zuo Zongtang's forces advanced into Xinjiang, Bai was placed in charge of defending Urumqi. In August of 1876, When Zuo's army approached the city, Bai fled, and Urumqi fell to the Qing. Some sources record that around this time, Zuo's army requested that Yaqub Beg hand Bai Yanhu over to them. This request received no response from Yaqub Beg. After the fall of Urumqi, Bai fled from city to city in Xinjiang, until he eventually fled to Russian territory with several thousand of his followers. They settled in the Chu Valley, in what is now Kyrgyzstan. Zuo attempted to convince Russia to extradite Bai Yanhu, but Russia refused and Bai lived in Russian territory until his death several years later.