left the official Wei Wensheng () in actual charge of the city. Later that year, when the general Yang Xuangan rebelled and attacked the eastern capital Luoyang, it was Wei who led troops from Chang'an to aid Luoyang's defenses. In 617, the general Li Yuan, fearful of Emperor Yang because Emperor Yang had become displeased with him over his inability to defend against Tujue attacks and suspicious of him after there had been prophecies that the next emperor would be named Li, rebelled at his headquarters at Taiyuan (太原, in modern Taiyuan, Shanxi). Li, wanting to both distance himself from Emperor Yang while declaring to the Sui forces that he was still loyal to Sui, claimed that his goal was to support Yang You as emperor and to persuade Yang Guang to return from Jiangdu (江都, in modern Yangzhou, Jiangsu) as Taishang Huang (retired emperor). Li proceeded quickly to Chang'an, and during Li's campaign, Wei died. Wei's lieutenants Yin Shishi () and Gu Yi () were left in charge of the city and guardianship over Yang You. In winter 617, Li's forces breached Chang'an's defenses. Li took Yang You and declared him emperor (as Emperor Gong), remotely offering Emperor Yang the title of Taishang Huang, but only territory under Li's control recognized Yang You as emperor. Reign While Emperor Gong was emperor, the real power was in Li Yuan's hands, and Li had Yang You make him the Prince of Tang. Quickly, the surrounding commanderies, including most of modern Shaanxi, Sichuan, and Chongqing, submitted to Li. With Luoyang under attack by the rebel leader Li Mi, in spring 618, Li sent troops commanded by his sons Li Jiancheng and Li Shimin there, claiming to be aiding the defense. The Sui forces at Luoyang refused to recognize Li's authority and made no contact with Li Jiancheng's and Li Shimin's forces, which withdrew after brief engagement with Li Mi's forces. In summer 618, just six months after Yang took imperial title, Li had Yang pass the throne to him, establishing Tang dynasty as its Emperor Gaozu. After reign The new emperor created the former emperor the Duke of Xi. The duke died in fall 619, and while traditional histories did not directly state so, they implied that he was killed on the Tang emperor's orders. He had no sons, and his title was inherited by a distant nephew, Yang Xingji (). Notes