In 617, Li Yuan indeed rebelled, and soon captured Chang'an, declaring Emperor Yang's grandson Yang You the Prince of Dai emperor (as Emperor Gong) but seizing power as regent. Knowing that Li Jing was planning to report his plans to Emperor Yang, Li Yuan set to execute him. At the execution, Li Jing yelled, "You, duke, rose in order to eliminate tyrannical rule for the people. You are not concerned about what is important, but instead are executing a brave man on account of personal enmity!" Li Yuan was impressed by his words, and Li Yuan's son Li Shimin interceded on Li Jing's behalf. Li Yuan released Li Jing, whom Li Shimin soon retained Li Jing to serve on his staff.