In 617, the governor of Taiyuan Li Yuan rebelled against the rule of Emperor Wen's son Emperor Yang, and by 618 had established Tang Dynasty at Chang'an (as its Emperor Gaozu).
Later in Emperor Gaozu's reign, Li Shimin was locked in an intense rivalry with his older brother Li Jiancheng the Crown Prince, and Fang and Du often suggested that he act first against Li Jiancheng.