One of the conditions of the peace treaty between France and China that ended the Sino-French War was that Liu Yongfu and the Black Flag Army should leave Tonkin. By the end of the war Liu had only around 2,000 troops under his command and was in no position to resist pressure from Tang Jingsong and the other commanders of the Yunnan Army to remove the Black Flag Army. Liu crossed into China with some of his most loyal followers, but the bulk of the Black Flag Army was disbanded on Tonkinese soil in the summer of 1885. Unpaid for months and still in possession of their rifles, most of the unwanted Black Flag soldiers immediately took to banditry. It took months for the French to reduce them, and the route between Hung Hoa and the border town of Lào Cai was only secured in February 1886. Meanwhile, the Qing government rewarded Liu Yongfu for his services in the Sino-French War with a minor military appointment in Guangdong province.