The lives of the people became very difficult due to Emperor Yang of Sui's unreasonable military campaigns against Goguryeo and massive construction projects like the Grand Canal. Unable to endure any longer, peasants and local soldiers started rebellions (uprisings to overthrow the government) everywhere. In 617, as the country was heavily shaken, Li Yuan, the Duke of Tang, and his brilliant son Li Shimin, who were guarding the important northern defense city of Taiyuan, gathered an army to restore order. They quickly marched south, persuading or defeating surrounding factions, and captured the capital, Chang'an. The following year, in 618, Emperor Yang, who had fled, was betrayed and killed by his own men, leading to the complete collapse of the Sui Dynasty. Li Yuan then founded the new Tang Dynasty and became Emperor Gaozu.
Although the Tang Dynasty was established, the whole of China was not yet united. Several powerful warlords (military leaders who control specific regions), such as Wang Shichong and Dou Jiande, threatened the Tang Dynasty from various places. During this early crisis, the military genius of his son Li Shimin shone brightly. In 621, Li Shimin faced a massive coalition army formed by Wang Shichong and Dou Jiande at a narrow and rugged fortress called Hulao Pass. Waiting patiently for the enemy's weakness, Li Shimin launched a brilliant surprise attack and won a great victory. With this triumph, the Tang Dynasty completely took over the North China Plain, the heartland of China, crossing the biggest hurdle towards unification.
The second son, Li Shimin, made the greatest contribution to defeating external enemies and unifying the country. However, the first in line to inherit the throne was his older brother, Crown Prince Li Jiancheng. This led to a fierce and scary power struggle between the brothers over who would become the next emperor. Believing that his older brother Li Jiancheng and younger brother Li Yuanji were plotting to harm him, Li Shimin eventually ambushed and killed them at the Xuanwu Gate, the northern gate of the imperial palace, in 626. This terrible event is known as the Xuanwu Gate Incident. Deeply shocked, his father Emperor Gaozu handed over the emperor's seat to Li Shimin shortly after, making him Emperor Taizong, the second emperor of the Tang Dynasty.
After becoming emperor, Tang Taizong (Li Shimin) practiced excellent politics and quickly stabilized the inside of the country. He then turned his attention to the Eastern Turkic Khaganate, a powerful nomadic empire in the north that had constantly harassed China since the Sui Dynasty. In 630, Taizong entrusted a large army to the great general Li Jing to attack the Eastern Turks. Amidst a fierce blizzard, the Tang army launched a lightning-fast surprise attack, completely destroying the Eastern Turks and capturing their supreme leader, the Khagan. With this victory, the Tang Dynasty gained control over the Silk Road (an important trade route connecting the East and the West) in Central Asia, opening a dazzling golden age that would last for hundreds of years.