Li Yuan establishes the Tang Dynasty

Li Yuan, courtesy name Shude, was born in Chengji, Longxi (present-day Yebao Township, Qin'an, Gansu Province). His father served as a high-ranking official during the Northern Zhou Dynasty, and his mother was the elder sister of Emperor Wen of Sui's Empress Dugu. After Emperor Yang of Sui ascended the throne, Li Yuan served as the governor of Loufan (present-day Jingle, Shanxi) and Xingyang (present-day Zhengzhou, Henan).

In 613 AD, Emperor Yang of the Sui Dynasty dispatched a large army to attack Liaodong. Li Yuan was sent to Huaiyuan Town to oversee the transport of fodder. Taking advantage of the widespread public discontent, Yang Xuangan launched a rebellion. Emperor Yang ordered Li Yuan to guard Honghua Commandery (present-day Qingyang, Gansu) and defend against Yang Xuangan's advance. After Yang Xuangan's defeat, Li Yuan remained in Honghua as its governor. During this time, Li Yuan did many things that benefited the people and also befriended many heroes and gallant figures.

In 617 AD, Li Yuan was appointed as the garrison commander of Taiyuan, tasked with suppressing peasant rebel armies. Taiyuan was a strategic military stronghold with ample troops and enough military grain to last ten years. Therefore, Li Yuan was particularly pleased and planned to develop his own power there. Upon arriving in Taiyuan, he led his troops to defeat the peasant rebel army south of the city, thereby consolidating his position. Later, Li Yuan sent his eldest son, Li Jiancheng, to make connections with heroes and gallants in Hedong, and his second son, Li Shimin, to recruit talented individuals in the Jinyang region.

At that time, Taiyuan, where Li Yuan was stationed, was repeatedly harassed by the Tujue, a northern ethnic group. Li Yuan led troops to resist but suffered several consecutive defeats. If this matter were to be discovered by the imperial court, Li Yuan's situation would become extremely perilous.

The safety of the nation and his own precarious situation left Li Yuan deeply troubled. His second son, Li Shimin, was a man of great courage and insight. Seeing his father constantly frowning with worry, he said to him, "Emperor Yang of Sui is debauched and tyrannical, provoking widespread anger and resentment. Now peasant uprisings have erupted across the country, all seeking to overthrow his brutal rule. Father, though you are a minister of the Sui court, the emperor is benighted and unjust—why must you sacrifice yourself for him? In my view, it would be better to raise an army against the Sui and join forces with the heroes of the realm to topple the dynasty."

Li Shimin's words made Li Yuan tremble with fear. Li Yuan said, "How can you say such things? This is treason and rebellion against your superior. If anyone else hears these words, your life will be in danger. Never speak like this again, do you understand?"

Li Shimin saw that his father's attitude was very firm, so he had no choice but to leave. However, he did not give up trying to persuade his father to raise an army against the Sui Dynasty. The next day, he said to Li Yuan again, "You have been appointed by the emperor as the Grand Protector of Taiyuan, responsible for guarding Taiyuan. But now, the Turks are constantly harassing us, and the peasant rebel forces are numerous and powerful; you simply cannot ensure the safety of Taiyuan. If the imperial court investigates, your situation will become very dangerous. Moreover, even if you manage to secure Taiyuan and achieve great merit, the emperor is extremely suspicious, and your situation could become even more perilous. So, if you continue to maintain the status quo, danger will always be by your side. To completely escape this danger, I believe the only path is for you to raise an army against the Sui."

Li Yuan found Li Shimin's words reasonable, but he could not muster the resolve to rebel against the Sui, fearing that failure would lead to the execution of his entire clan.

Li Shimin added, "Now rebellions are breaking out everywhere, and the government forces are scattered, making them easy to deal with." His words completely dispelled Li Yuan's doubts. Finally determined to raise an army against the Sui Dynasty, Li Shimin then recommended his friend Liu Wenjing to Li Yuan.

After this, Li Yuan sent Liu Wenjing to recruit troops and summoned his eldest son Li Jiancheng and fourth son Li Yuanji back from the battle in Hedong.

Wang Wei and Gao Junya were the deputy governors of the prefecture, loyal to Emperor Yang of the Sui Dynasty. After observing Li Yuan's actions, they began to suspect that Li Yuan was secretly plotting a rebellion. Li Yuan knew that these two could not be kept around for long, as they would surely report his rebellious intentions to Emperor Yang. Therefore, he made up his mind to eliminate both Wang and Gao.

One morning, Li Yuan was discussing official matters with Wang Wei and Gao Junya. Liu Wenjing led Liu Huizheng, the Sima of Kaiyuan Prefecture, before them. Liu Huizheng said he had a confidential document to present to Li Yuan. Li Yuan asked him to submit it. Liu Huizheng stated that the deputy commanders were the ones he was accusing, so they could not see it—only Li Yuan could. Li Yuan deliberately feigned shock, saying, "How could such a thing happen?" Then he took the document and read it. After reading, he told the others, "Wang Wei and Gao Junya are traitors; they planned to collude with the Turks to launch a coordinated attack on Taiyuan City." Li Yuan then ordered soldiers to arrest them. The next day, Taiyuan was besieged by tens of thousands of Turks, which convinced everyone of Wang and Gao's collusion with the Turks, allowing Li Yuan to execute them with justified authority.

After eliminating internal threats, dealing with the Turkic army became a pressing challenge for Li Yuan. He ordered Liu Wenjing and others to hold the city walls, but no banners were raised on the walls, the city gates were left open, and soldiers were forbidden from making noise or looking around. The Turkic forces, uncertain of the situation, dared not rashly enter the city. Li Yuan also sent his generals with a detachment of troops to leave the city at night and re-enter through a different route in the morning, creating the illusion of arriving reinforcements to deceive the Turks. This strategy proved highly effective, as the Turkic army truly believed reinforcements had arrived and withdrew. Although the siege was lifted, there was no guarantee the Turks would not return. To completely resolve the issue and eliminate future concerns for his rebellion against the Sui Dynasty, Li Yuan wrote a letter to the Turkic Khan in a subordinate tone. In the letter, he stated: "If you refrain from raiding the people of Taiyuan, I am willing to send all the wealth gained from conquests to the Khan."

After this, Li Yuan officially raised an army and marched toward Chang'an. Xihe Commandery was the first obstacle on the westward advance. Li Shimin and Li Jiancheng led a large force and captured Xihe Commandery in just nine days. Subsequently, Li Yuan established the General-in-Chief's headquarters, proclaimed himself General-in-Chief, appointed Li Jiancheng as Duke of Longxi and Grand Commander of the Left Army, appointed Li Shimin as Duke of Dunhuang and Grand Commander of the Right Army, and appointed Liu Wenjing and Pei Ji as Chief Clerk and Adjutant.

Li Yuan's army advanced with unstoppable momentum and quickly broke into the city of Chang'an. After capturing the city, Li Yuan announced twelve articles of law, which were warmly welcomed by the local residents. Seeing that the time was not yet ripe for him to claim the throne, he installed Yang You, the grandson of Emperor Yang of Sui, as emperor, changed the reign title to Yining, and honored Emperor Yang, who was then in Jiangdu, as the Grand Emperor. Li Yuan appointed himself as Grand Chancellor and Prince of Tang, holding all military and political power.

In the summer of 618 AD, Emperor Yang of the Sui Dynasty, who was indulging in pleasures while hiding in Jiangdu, was surrounded by the general Yuwen Huaji and the imperial guards. The emperor angrily demanded, "How dare you commit such treason? Do you not know this is a capital offense? Who ordered you to do this?"

The imperial guards replied, "You tyrant, everyone under heaven hates you to the bone and wishes to cut you into a thousand pieces. Do we need someone else to lead us in killing you?" Yuwen Huaji ordered his men to strangle Emperor Yang of Sui to death, then installed Yang Hao as emperor and declared himself Grand Chancellor. Upon hearing this news, Li Yuan was overjoyed, because with Emperor Yang dead, he could legitimately claim the throne for himself.

In 618 AD, Li Yuan declared himself emperor, established the Tang Dynasty with its capital at Chang'an, and became known as Emperor Gaozu of Tang.