Li Gui
Li Gui, courtesy name Chuze, was the emperor of a short-lived state of Liang, which he established at the end of the Chinese Sui Dynasty. He governed the parts of modern Gansu west of the Yellow River. In 618, he briefly considered submitting to Emperor Gaozu of Tang, with whom they both believed he had a distant family relationship, but ultimately rejected the idea. In 619, the Tang Dynasty official An Xinggui pretended to submit to him, and then started an uprising at his capital Wuwei, overthrowing him and turning him over to Emperor Gaozu, who executed him.
As prince
Li Gui was from Wuwei Commandery, and he served as a militia officer in the local government. His family was said to be rich, and he used his wealth to help those who were poor, and thus gained a good reputation. He was also said to be well-read and capable in debating and logic. In summer 617, when Xue Ju rebelled against Sui Dynasty's rule at Jincheng, Li discussed with his associates Cao Zhen, Guan Jin, Liang Shuo, Li Yun, and An Xiuren the possibility of also rebelling against Sui rule – under the reasoning that they were fearful that Xue would pillage Wuwei unless someone resisted, and the Sui officials were not capable of doing so. They resolved to do so, and when it came time to decide on a leader, Cao suggested that because prophecies had indicated that the next emperor would be named Li, that Li Gui should be their leader.In fall 617, Li had An gather the Xiongnu chiefs of the region, while he himself gathered the prominent families among the Han, and they rose together, arresting the Sui officials Xie Tongshi and Wei Shizheng. Li claimed himself the title of "the Great Prince of Liang west of the River," and adopted a governmental structure modelled after that of Sui's founder Emperor Wen. Guan proposed that the Sui officials be slaughtered and that their wealth be divided. Li responded: "You forced me to be leader, so you should listen to my orders. We rose in righteousness to save the people; if we murder for money, we are just bandits, and how can we achieve great things?" He invited Xie and Wei to join his administration. The Western Tujue general Ashina Kandu, claiming the title of Kan Khan, also submitted to him.
Soon, Xue sent his general Chang Zhongxing to cross the Yellow River to attack Li Gui. Li Gui sent Li Yun to resist Chang, and Li Yun defeated Chang and captured all of his army. Li Gui wanted to release Chang's soldiers, but Li Yun opposed, believing that they would flee back to Xue and attack again; rather, Li Yun proposed that they all be slaughtered. Li Gui responded, "If Heaven protects me, I will eventually capture their leader, and they will all be mine. if Heaven does not protect me, it is useless for me to keep them." He therefore released them. Li Gui soon took four other commanderies – Zhangye, Dunhuang, Xiping, and Fuhan, controlling the territory west of the Yellow River. Soon, however, Ashina Kandu rebelled, but Li Gui was able to defeat and destroy him.
Meanwhile, Emperor Gaozu of Tang, who had established Tang Dynasty in spring 618 and wanted to enter an alliance with Li Gui to attack Xue Ju's successor Xue Rengao, sent messengers to Li Gui, calling him "younger cousin." Li Gui was pleased, and he sent his brother Li Mao to the Tang capital Chang'an to greet Emperor Gaozu. Emperor Gaozu, in response, sent his official Zhang Qide to Wuwei to commission Li Gui as the commandant of Liang Prefecture and created him the Prince of Liang. Before Zhang could arrive at Li Gui's domain, however, Li claimed imperial title in winter 618. He created his son Li Boyu as crown prince.
As emperor
Once Li Gui claimed imperial title, however, his governance appeared to deteriorate. He initially trusted Liang Shuo, whom he regarded as intelligent, as his chief strategist. However, as Liang Shuo realized that the Xiongnu chiefs were becoming increasingly powerful, he advised Li Gui to curb their powers, and so made an enemy out of An Xiuren, who was the leader of the Xiongnu chiefs. Further, when Li Gui's son Li Zhongyan visited Liang Shuo, Liang Shuo did not respect him, and so Li Zhongyan, displeased, along with An, jointly accused Liang Shuo of treason, and so Li Gui poisoned Liang Shuo to death. Also around this time, a sorcerer told Li Gui that a goddess was about to be sent to him from heaven, and Li Gui thus built a tower to be ready to welcome the goddess. Further, at that time, Li Gui's realm was suffering from a famine, and Cao Zhen suggested that the food supplies be given to the hungry. However, Xie Tongshi, who wanted to undermine Li Gui's rule, instead told Li Gui that those who were starving were all weak anyway and that he should not waste food on the weak – suggesting that all Cao was doing was trying to gain popularity. Li Gui agreed and withheld food rations, causing the people to lose their respect for him.In spring 619, Zhang Qide arrived in Liang territory. Li Gui, upon hearing Emperor Gaozu's offer, indicated that he was inclined to accept – as he saw Emperor Gaozu as a cousin, and that he should then accept the Tang-bestowed title of Prince of Liang. Cao disagreed, suggesting that he should not prostrate himself to Tang, but rather, if he wanted to submit, he should use the model Emperor Xuan of Western Liang used when submitting to Northern Zhou – continuing to use imperial title, but at the same time declaring himself a subject. Li Gui agreed, and he sent his official Deng Xiao to Chang'an, and he, while declaring submission to Emperor Gaozu, used for himself the title of, "Your subject and younger imperial cousin, Li Gui the Emperor of Liang." Emperor Gaozu was displeased and detained Deng, and he began to discuss an attack on Li Gui. He sent messengers to enter into a peace treaty with Tuyuhun's Busabuo Khan, Murong Fuyun, offering to return Murong Fuyun's son Murong Shun. Murong Fuyun was pleased, and attacked Liang as per Tang instructions, to weaken Li Gui.
Defeat and death
In summer 619, An Xiuren's brother An Xinggui, then serving as an official under Tang's Emperor Gaozu, proposed that he go to Liang to try to persuade Li Gui to submit. He further told Emperor Gaozu that his plan was to first try to persuade Li Gui, but that if he was unable to do that, he would rise against Li Gui and overthrow him. Emperor Gaozu agreed with the plan.Once An Xinggui arrived in Wuwei, Li Gui made him a general. He tried to persuade Li Gui to submit to Tang and offer his territory to Tang. Li Gui refused, believing that he could defend his realm against Tang. An Xinggui then plotted with An Xiuren, and they gathered the Xiongnu people to attack Li Gui. Li Gui was unable to withstand the attack, and withdrew within Wuwei. An Xinggui put Wuwei under siege, while calling for the people to surrender. The people of Wuwei exited the city in droves to surrender to An Xinggui. Li Gui, seeing that the situation was hopeless, climbed up the tower he built for the goddess, along with his empress, holding one final feast of farewell. An Xinggui soon entered the city and captured him, delivering him to Chang'an. Emperor Gaozu executed him and his sons and brothers.