Yang-ti (605 to 617 AD) reigned as the last Sui emperor. He undertook numerous public works projects that required tremendous manpower. In northern Shansi alone, he used more than 1 million men to repair and rebuild a long section of the Great Wall. Hundreds of thousands of Chinese laborers were forced to dredge canals, build lavish palaces, and construct roads. Then, with his people warn exhausted from the massive public works projects, Yang-ti launched three massive assaults against the Koguryo Kingdom of North Korea. The results were disastrous as the Chinese were met by strong resistance. Before long, Yang-ti's people couldn't take it anymore. They revolted and chaos quickly followed. Not long after, China broke out in civil war and Yang-ti was assassinated in 618 by one of his own officials.
At the time of the Sui collapse, the Tang was just one of many powerful factions that sought to succeed the Sui. However, they were led by Li Yuan, and Li Yuan was a well respected military leader who served during the Sui dynasty. Li Yuan and the Tang would emerge victorious largely do to their impregnable mountain fortress and brilliant military leaders. Li Yuan named his new dynasty, the Tang, after his fiefdom in Shansi. However, it would take until 628 AD, before the Tang could suppress the last rebel group. After the fall of the Sui, the Tang were forced to undertake a series of measures so that they could reestablish control over the areas that had recently come under their control. They did this by dividing the country into 300 prefectures and 1500 counties. All of the prefectures were under the direct control of the central Tang government, and they were divided so that no individual prefecture had enough power to seek independence. The Tang administered their highly centralized government with a complex system of law.
Under the leadership of the Tang, China became a much more cosmopolitan society. During the Tan dynasty people from all parts of the known world traded goods in China. Before long, large merchant trading communities of Jews, Iranians, Persians, and Arabs emerged in the capital cities of Lo-yang and Chang'an, as well as in the port cities of Canton and Yangchow. These people brought with them new religions and new cultural traits, and the Tang allowed them to live in these communities according to their own customs and laws. Eventually, the foreign populations of these cities swelled to over 100,000.
Commerce flourished under the Tang. At this time, most foreign trade came by way of the Central Asian caravan routes. However, by 760 overland routes were abandoned for sea routes. Ships from Canton and Yangchow left on a regular basis for India, Persia, Malaysia, Ceylon, Korea, Japan, and the Middle East. The economies of both Canton and Yangchow flourished, and the result was their populations swelled.
The 8th and 9th centuries saw an enormous population shift south to the Yangtze Valley which had the most fertile ground. The large surplus of food produced in the valley increased trade and commerce. It also brought new industries, new towns, and a new powerful class of merchants. However, in the 830's the Yangtze Valley was hit by a series of floods, droughts, and insect invasions. By the 860's banditry and social disorder were common. The empire would completely fall apart in 907.