In 881 the Tanguts assisted the Tang in suppressing the Huang Chao rebellion. As a reward the Tang granted the Tangut general Li Sigong the three prefectures of Xia (, Tangut: ), Sui (, Tangut: ), and Yin (, Tangut: ) as hereditary titles under the Dingnan Jiedushi. From there the Tanguts expanded their realm southwest towards their old homelands. In 1002 they conquered Ling Prefecture and set up their first capital there under the name of Xiping. By 1036 they had annexed the Guiyi Circuit and the Ganzhou Uyghur Kingdom, even pushing into Tibetan territory and conquering Xining. The state of Western Xia was proclaimed in 1038.