Li Yuan captured Chang'an in winter 617 and declared Emperor Yang's grandson Yang You emperor (as Emperor Gong), taking power himself as regent.
By 623, however, Li Shimin was locked into an intense rivalry with Li Jiancheng, who was supported by another brother, Li Yuanji the Prince of Qi.