Emperor Gaozu put Qin Shubao under Li Shimin's command. Around the new year 620, with
Liu Wuzhou the Dingyang Khan having seized most of Tang territory in modern
Shanxi and aiming to attack further south, Emperor Gaozu sent Li Shimin to resist Liu, and Qin and
Yin Kaishan were able to defeat Liu's general
Yuchi Gong at Meiliang River (美良川, flowing through modern
Yuncheng,
Shanxi), repelling Yuchi's offensive. Impressed, Emperor Gaozu sent a messenger to award Qin a golden bottle, stating to him: You disregarded your wife and children to follow me, and you have accomplished great things. If my flesh can be beneficial to you, I would be willing to cut it off for you, and I will spare no servants, jade, or silk. Be encouraged. Qin then followed Li Shimin in defeating Liu's major general Song Jin'gang (), contributing to Li Shimin's final victory over Liu later in 620. Emperor Gaozu awarded Qin with a large supply of gold and silk. Later that year, Li Shimin launched a major attack against Wang, who by this point had deposed Yang Tong and declared himself emperor of a new state of Zheng. During the campaign, Li Shimin selected some 1,000 elite soldiers, clad in black uniform and black armor, commanded by Li Shimin himself, to serve as the forward advance corps, with Qin, Cheng Zhijie, Yuchi (who by this point had surrendered to Tang), and Zhai Zhangsun () as his assistants. This corps subsequently accomplished much during the campaign against Wang and
Dou Jiande the Prince of Xia, who came to Wang's aid. During initial engagement against Xia troops, Qin, Yuchi, and
Li Shiji were able to defeat Xia forward troops, and Li Shimin subsequently wrote Dou, citing the battle as a reason why he should stop his campaign to aid Wang. Dou did not relent, and in summer 621, his and Li Shimin's troops engaged at the
Battle of Hulao. Qin contributed much during the battle, which ended with Dou's being captured by Tang forces. Wang subsequently surrendered, and both Zheng and Xia territory were seized by Tang (although later that year Dou's general
Liu Heita rose against Tang rule and briefly recaptured nearly all of Xia territory). For his achievements against Zheng and Xia forces, Qin was created the Duke of Yi. In 622, he also followed Li Shimin in fighting against Liu Heita. It was said that whenever Qin was following Li Shimin in battle, where there would be enemy soldiers who dared to display their bravery and taunt Li Shimin, Li Shimin would send Qin to attack them, and often Qin was able to target them and destroy them. Li Shimin therefore was particularly impressed with him, and Qin was proud of his own abilities. in 626, Li Shimin, then locked in an intense rivalry with his older brother
Li Jiancheng the
Crown Prince and fearful that Li Jiancheng would kill him, set an ambush for Li Jiancheng and another brother,
Li Yuanji the Prince of Qi, who supported Li Jiancheng, at
Xuanwu Gate. Qin was one of the key commander of Li Shimin's forces, which subsequently killed Li Jiancheng and Li Yuanji. Li Shimin then effectively forced Emperor Gaozu to name him crown prince and then pass the throne to him (as Emperor Taizong). ==During Emperor Taizong's reign==