Gaitu guiliu 改土歸流 "transforming chieftainships into district administration" was a policy of abolishing the indirect rule of the territories of native tribes (today called "national minorities") through local chieftains (tusi 土司) and its replacement by a "normal" (liu 流) direct administration through prefectures and districts, particularly in the southwestern provinces, during the Ming 明 (1368-1644) and Qing 清 (1644-1911) periods.
The system of chieftainships had been created during the Yuan period 元 (1279-1368) and reached its mature state during the Ming. The Ming court formally invested the tribal chieftains with Chinese offices like pacification commission (xuanweisi 宣慰司, xuanfusi 宣撫司 or anfusi 安撫司) or bandit suppression commission (zhaotao si 招討司). Their subordinates were also given offices as so-called "native officials" (tuguan 土官) with the titles of "native prefects" (tu zhifu 土知府) or "native magistrates" (tu zhixian 土知縣), and were handed over official seals (yinxin 印信). These offices were hereditary, and this indirect system of rule (jimi 羈縻) there did not greatly change the social and political structure of the native tribes, and allowed them to retain substantial autonomy. In some regions, independent native villages existed side by side with districts and prefectures (a situation called tu-liu hezhi 土流合治 or tu-liu canzhi 土流參治).
The Ming carried out a transformation of the native territories into districts when native tribes rebelled against the imperial government, when quarrels between native chieftains infringed on imperial territory, when a chieftain was killed or had no heirs, or was guilty of some offence. In some instances, chieftains were appointed district magistrates in the new system. In others, appointees from Chinese provinces were reluctant to serve in the remote and malaria-infested regions of the southwest, and the posts remained vacant, allowing the chieftains to retain their power over the local populations. Finally, there were new district officials who continued using the traditional local system of taxation, thus allowing the chieftains to keep their jurisdictional rights.
There were two main problems with this system of indirect rule, namely first, the incessant clashes between different tribes which often erupted in wars, sometimes spreading on regular district territory, and secondly, clashes between the native tribes and Chinese settlers. The first large-scale conflict arose in 1413 between the chieftains of Sinan 思南 and Sishuai 思帥 in the province of Guizhou which provoked a military campaign to put down the upheaval. Emperor Chengzu 明成祖 (r. 1402-1424) decided to abolish the chieftainships in that region, and replaced it with eight prefectures administered under a provincial administration commission (buzhengshi si 布政使司).
During the early decades of the Qing period large tracts of the provinces of Hubei, Hunan, Guizhou, Sichuan and Guangxi were more or less autonomous. This did not even change after the end of the rebellion of the Three Feudatories 三藩之亂, whose heads had critically relied on the support of native tribes. Yet in 1726 the governor-general (zongdu 總督) of Yun-Gui 雲貴 (Yunnan and Guizhou), Ortai 鄂爾泰 (1677-1745), who invested greatest efforts into the development of the southwestern region, suggested to abolish the system altogether, in order to bring peace and stability to the remote provinces. The Yongzheng Emperor 雍正 (r. 1722-1735) accepted his proposal, appointed him governor-general of Yunnan, Guizhou and Guangxi, and ordered him to carry out the transformation. Endowed with greatest authority, Ortai invited the chieftains to accept the change of the administrative system, and whoever refused, was forced by military means. The insistent conflicts between chieftains provided a useful argument to arrest them or to annihilate their villages. More than 2,000 stockaded villages (zhai 寨) of the Miao 苗 and Yao 瑶 in Guizhou were registered over the next years and forced to accept the abolishment of their autonomy.
The first was the village of Changzhai 長寨 that was transformed into the sub-prefecture of Changzhai 長寨廳 (today Changshun 長順, Guizhou). The next plan was to change the jurisdiction of the native prefectures of Wumeng 烏蒙, Zhenxiong 鎮雄 and Dongchuan 東川, belonging to Sichuan, by subordinating it to the province of Yunnan. For this purpose, Ortai dispatched troops to punish the chieftains of Wumeng and Zhenxiong, and to enforce the creation of the prefectures of Wumeng (today Zhaotong 昭通, Yunnan) and Zhenxiong. In 1727 the chieftain of the native prefecture of Sicheng 泗城 was dismissed and the prefecture of Yongfeng 永豐 (today Zhenfeng 貞豐, Guizhou) created.
A year later the surveillance commissioner (anchashi 按察使) of Guizhou, Zhang Guangsi 張廣泗 (d. 1749), was entrusted with the implementation of the gaitu guiliu policy in Guizhou. He marched into the recalcitrant native prefecture of Liping 黎平 and forcibly created a regular prefecture. While those chieftains who willingly handed in their official seals and accepted the loss of their authority were rewarded, could retain inheritable positions, or were given military positions, those showing resistance were cruelly punished, and the people of their tribes forcibly resettled into various provinces. In order to be ready in case future rebellions should occur, military garrisons were built all over the southwestern provinces.
In 1731 the whole territory of Guizhou was converted into directly administered prefectures. This also meant that the population was registered for taxation, land was registered for fixing ownership, and the normal infrastructure was created, including government seats, temples and schools. In some respect, the transformation into a regular administrative system, alleviated the burden of the native population, taking from them the duty of services and taxes formerly delivered to the chieftains. Yet the first result was that exploitation by the new local officials was so weird, and treatment so unfair that many Miao tribes decided to rebel in 1735. Zhang Guangsi, appointed military commissioner (jinglüe 經略) over seven provinces, appeased the region, and the Qianlong Emperor 乾隆 (r. 1735-1796) decided to apply a reduced rate of taxes, in order to prevent further upheavals, and to adapt it to local custom.
The two wars in western Sichuan/eastern Tibet against the chieftains of rGyalrong and bTsanlha (Da Jinchuan 大金川, Xiao Jinchuan 小金川) initiated the thorough abolishment of native rule in that province. In Guangxi many regions remained under indirect rule, and it is still today an Autonomous Region (zizhiqu 自治區). In the other provinces the change of the administrative system contributed to the economical, social and political integration of southwest China into the rest of the country.
Even if the gaitu guiliu policy ended the warlike quarrels between native tribes, it did not end conflicts and disagreements about the ownership of land in the region. Such disputes continued well into the twentieth century.