In 618, after news arrived at Chang'an that Emperor Yang was killed in a coup at Jiangdu led by the general Yuwen Huaji, Li Yuan had Yang You yield the throne to him, establishing Tang Dynasty as its Emperor Gaozu. Li Jing continued serving the new dynasty. In 619, Li Jing participated in a campaign against one of Tang's major enemies, Wang Shichong the Emperor of Zheng, and was promoted for his accomplishments. Later that year, Emperor Gaozu sent him to Kui Prefecture (夔州, modern eastern Chongqing) to plan a military operation against another major enemy, Xiao Xian the Emperor of Liang, who then ruled the modern Hubei, Hunan, and Guangxi region. When he first reached Jin Prefecture (金州, roughly modern Ankang, Shaanxi), he encountered bandits in the mountain, who had several times defeated Li Yuàn (李瑗, note different tone and character than Emperor Gaozu's name (淵, yuān)) the Prince of Lujiang (Emperor Gaozu's distant nephew). Li Jing joined forces with Li Yuàn to defeat those bandits. However, as he arrived at the borders with Liang, he was blocked by Liang forces and long could not reach there, having to stop at Xia Prefecture (峽州, roughly modern Yichang, Hubei). Emperor Gaozu, believing that Li Jing was intentionally not advancing, was sufficiently angry that he secretly ordered the commandant at Xia Prefecture, Xu Shao (許紹), to execute Li Jing. Xu, however, was appreciative of Li Jing's talent, and submitted a petition urging that Li Jing be spared, and Emperor Gaozu relented. Meanwhile, in spring 620, around the same time, Ran Zhaoze (冉肇則) the leader of the Kaishan Tribe (開山蠻), rebelled against Tang rule and attacked Kui Prefecture. When Emperor Gaozu's distant nephew Li Xiaogong the Duke of Zhao Commandery fought Ran, he was initially unsuccessful, but Li Jing reinforced him with 800 men and defeated and killed Ran.