Liang Shidu (梁師都) (died June 3, 628) was an agrarian leader who rebelled against the rule of the Chinese Sui dynasty near the end of the reign of Emperor Yang of Sui. He, claiming the title of Emperor of Liang with the aid from Eastern Turkic Khaganate retained the modern northern Shaanxi and western Inner Mongolia region for over a decade, but was gradually weakened by attacks from the Tang dynasty, whose founding emperor Emperor Gaozu and successor Emperor Taizong had eliminated the rival contenders for power one by one, leaving Liang isolated. In 628, with the Eastern Turks in internal turmoil and unable to come to his aid, Emperor Taizong launched another attack on Liang. Liang's cousin Liang Luoren (梁洛仁) assassinated him and surrendered, completing Tang's drive to reunite China after Sui's collapse.
 Liang Shidu was from a prominent clan of Xia Province (夏州, roughly modern Yulin, Shaanxi), and during the reign of Emperor Yang of Sui, he served as a military officer. In or shortly before 617, he quit the army and returned to his home commandery (as Xia Province had been converted into the Shuofang Commandery). At that time, there were many agrarian rebellions in the region, and Liang gathered a group of men and ambushed the secretary general of Shuofang Commandery, Tang Shizong (唐世宗).  He initially claimed the title of grand chancellor (大丞相, Da Chengxiang) and entered into an alliance with Eastern Tujue.  When the Sui general Zhang Shilong (張世隆) tried to attack him, he defeated Zhang.  He thereafter captured several other nearby commanderies—Diaoyin (雕陰, in modern Yulin as well), Honghua (弘化, roughly modern Qinghua, Gansu), and Yan'an (延安, roughly modern Yan'an, Shaanxi). He submitted to Eastern Tujue's Shibi Khan Ashina Duojishi, who created him the Dadupiqie Khan (大度毗伽可汗) and bestowed on him a flag with a wolf head, the symbol of the Tujue. He guided Eastern Tujue forces to occupy the Ordos Desert region.  Subsequently, Ashina Duojishi forged the  title of Jieshi Tianzi (解事天子, i.e., "the Tianzi who solved issues") for Liang, although he himself declared a state of Liang and himself its emperor.
 Liang Shidu entered into an alliance with another rebel leader of the region, Guo Zihe (郭子和). In 618, with the Sui general Li Yuan having rebelled against Emperor Yang and entered the capital Chang'an, declaring Emperor Yang's grandson Yang You emperor (as Emperor Gong), another rebel ruler, Xue Ju the Emperor of Qin, entered into an alliance with Liang and Eastern Tujue, seeking to attack Chang'an. However, Li Yuan was able to persuade the Eastern Tujue general Ashina Duobi (Ashina Duojishi's brother) to give up the campaign. In fall 618, with Li Yuan having had Yang You yield the throne to him, establishing the Tang dynasty as its Emperor Gaozu, Liang tried to attack Ling Prefecture (靈州, roughly modern Yinchuan, Ningxia), which had submitted to Tang, but was repelled.
 In spring 619, Ashina Duojishi was planning on a major incursion into Chinese territory, and both Liang and another rebel ruler, Liu Wuzhou the Dingyang Khan, joined him.  However, Ashina Duojishi then died at this time, and his brother Ashina Qilifu succeeded him (as Chuluo Khan), and Ashina Qilifu terminated the campaign after receiving a large tribute from Tang.  Liang then again attacked Ling Prefecture but was again repelled.  In fall 619, he attacked Yan Prefecture (延州, i.e., the former Yan'an Commandery), which had submitted to Tang as well, but was repelled by the Tang general Duan Decao (段德操).  Another Liang attack in fall 620, in conjunction with Eastern Tujue, was also repelled by Duan.  Meanwhile, Liang's one-time ally Guo Zihe, who had submitted to Tang as well, had turned against Liang and Eastern Tujue, seizing Liang's city of Ningshuo (寧朔, in modern Yulin).  (Eastern Tujue, in response, imprisoned Guo's brother Guo Zisheng (郭子升), and Guo subsequently moved south to avoid Eastern Tujue forces.)
 Meanwhile, with his generals Zhang Ju (張舉) and Liu Min (劉旻) having defected to Tang and with Liu Wuzhou having been defeated by Tang earlier in 620, Liang was fearful that he would become next, and he sent his official Lu Jilan (陸季覽) to point out to Ashina Qilifu that he should act against Tang before it became too strong to control. Ashina Qilifu agreed, and made a grand plan to attack Tang on several sides, incorporating Xi tribe forces and those of another rebel ruler, Dou Jiande the Prince of Xia, into the plan.  However, before Ashina Qilifu could launch his plan, Ashina Qilifu died. He was succeeded by Ashina Duobi (as Jiali Khan).
 In spring 622, Duan launched an attack on Liang, capturing the eastern city of Liang's capital Shuofang, forcing Liang to withdraw to the western city. However, relief forces from Eastern Tujue arrived, and Duan withdrew. Liang subsequently sent his brother Liang Luo'er (梁洛兒) to, with Eastern Tujue forces, attack Tang's Ling Prefecture, but was repelled by the Tang general Li Daozong.
 In spring 623, Liang Shidu's generals He Sui (賀遂) and Suo Tong (索同) defected to Tang, along with the territory they controlled. In summer 623, Duan Decao launched another attack on Liang, reaching Shuofang, but withdrew after pillaging. In response, the Liang general Xin Liao'er (辛獠兒) guided Eastern Tujue troops to attack Tang's Lin Prefecture (林州, roughly modern Qingyang), and then Liang himself guided Eastern Tujue forces to attack Tang's Kuang Prefecture (匡州, also in modern Yulin).
 In fall 624, the major Liang official Bai Fuyuan (白伏願) defected to Tang.
 In 626, Emperor Gaozu's son Li Shimin the Prince of Qin, ambushed and killed his brothers Li Jiancheng the Crown Prince and Li Yuanji the Prince of Qi, and then effectively forced Emperor Gaozu to yield the throne to him (as Emperor Taizong).  Meanwhile, Liang himself saw his forces weakening, and suggested to Ashina Duobi that he invade Tang.  Ashina Duobi and his nephew, the subordinate Tuli Khan Ashina Shibobi (阿史那什鉢苾), jointly attacked the Tang capital Chang'an, but withdrew after Emperor Taizong personally met them and offered additional tributes.
 After this point, however, Eastern Tujue was itself in internal turmoil and had less ability to aid Liang.  Emperor Taizong therefore wrote Liang Shidu several times to try to persuade him to submit, but Liang refused. Emperor Taizong sent raiding forces to pillage Liang periodically, as well as to burn the crops, reducing Liang's food supplies, and also sent agents into Liang territory to damage the relationships between Liang and his officials.  In summer 628, when a number of Khitan tribes surrendered to Tang, Ashina Duobi offered to trade Liang for the Khitan tribes, but Emperor Taizong refused.
 Meanwhile, Emperor Taizong sent his brother-in-law Chai Shao (柴紹) and the generals Xue Wanjun (薛萬均), Liu Lancheng (劉蘭成), and Liu Min (Liang's former subordinate) to pressure Shuofang. They soon defeated Eastern Tujue forces and put Shuofang under siege, and Eastern Tujue forces were unable to lift the siege.  When the food supplies ran out, Liang Shidu's cousin Liang Luoren assassinated Liang Shidu and surrendered the city to Tang.