As early as the Spring and Autumn period, the Di lived in areas of present-day Gansu, Qinghai, Sichuan and Shaanxi.
In 111 BC, the Han dynasty established Wudu Commandery (武都郡; around present-day Longnan, Gansu) after defeating the local Di people.
During the end of the Han dynasty, Di chieftains such as Agui (阿貴) of Xingguo (興國; northeast of present-day Qin'an County, Gansu) and Yang Qianwan (楊千萬) of the White Neck Di (白項氐) allied themselves with the warlord, Ma Chao, against the Han Chancellor, Cao Cao.
Prior to the upheaval of the Five Barbarians, the Di, along with many other nomadic peoples in northwestern China, partook in a number of revolts against the Western Jin dynasty.
It became a haven for refugees fleeing the wars in the north, and due to the prevalence of Taoism in the region, the Taoist hermit, Fan Changsheng was appointed as the state's first Chancellor.
After Shi Hu's death and the collapse of Later Zhao that followed, Pu Hong attempted to break away by returning to Guanzhong, changing his family name to Fu (苻) and claiming the title of King of the Three Qins in the process.
With the early help of Wang Meng, a Han Chinese, as his prime minister, the Former Qin briefly unified northern China and became the largest of the Sixteen Kingdoms, conquering the Former Yan, Chouchi, Former Liang and Dai by 376 as well as Sichuan from the Eastern Jin dynasty.
Fu Jiān vied to complete the full unification of China, but following a disastrous defeat to the Eastern Jin at the Battle of Fei River in 383, his empire disintegrated as his generals took the opportunity to secede.
In 385, at the advice of the Buddhist monk, Kumārajīva, Lü Guang returned from Kucha and seized Liang province, making Guzang (姑臧, in modern Wuwei, Gansu) his capital.
The Later Liang was a highly-militaristic regime as they violently suppress their subjects and launched continuous attacks on the Western Qin dynasty.
It was ruled by the White Neck Di, which had briefly resided in the region before migrating to Lüeyang, but later returned under Yang Maosou to escape Qi Wannian's rebellion in 296.
In 580, Yang Yongan (楊永安), a Di chieftain in Shazhou (沙州; a name of a region that appears in offices granted by the Southern dynasties to the rulers of Yinping), joined Wang Qian in rebelling against the future Emperor Wen of Sui, but was defeated by Daxi Changru.