After Emperor Taizong took the throne, he made Li Shiji the commandant at Bing Prefecture (, roughly modern
Taiyuan,
Shanxi). In 629, when Emperor Taizong launched a major attack against Eastern Tujue's
Jiali Khan Ashina Duobi (a.k.a. Jieli Khan or Illig Qaghan), commanded by
Li Jing, Li Shiji was one of the major generals under Li Jing's command and was in charge of one of the four prongs of attack. In spring 630, after Li Shiji defeated Eastern Tujue forces at Baidao (, in modern
Hohhot,
Inner Mongolia) and after Li Jing defeated Ashina Duobi's main forces and forced Ashina Duobi to flee, he met with Li Jing and decided to, despite the fact that Ashina Duobi claimed to then seek peace, attack Ashina Duobi, defeating him again and capturing most of Ashina Duobi's remaining forces. (Ashina Duobi himself fled further and was later captured by forces under the command of Emperor Taizong's cousin
Li Daozong the Prince of Rencheng County.) Meanwhile, as Emperor Taizong's son
Li Zhi the Prince of Jin was made the nominal commandant of Bing Prefecture (but did not actually report to Bing), Li Shiji's title became the secretary general of Bing, but he continued to effectively serve as commandant. In 637, as part of Emperor Taizong's scheme to bestow prefectures on his relatives and great generals and officials as their permanent domains, Li Shiji's title was changed to Duke of Ying, and he was given the post of prefect of Qi Prefecture (, roughly modern
Huanggang,
Hubei), to be inherited by his heirs, but Li Shiji remained at Bing and did not actually report to Qi. Soon, however, with many objections to the system, the strongest of which came from
Zhangsun Wuji, Emperor Taizong cancelled the scheme, although Li Shiji's title remained Duke of Ying. In 641, when discussing about Li Shiji, whom historical accounts indicated that the people obeyed without complaints, Emperor Taizong made the comment: in winter 641, Emperor Taizong promoted him to the post of minister of defense. Soon, however, even before Li Shiji could leave for Chang'an,
Xueyantuo's
Zhenzhu Khan Yi'nan, believing that Emperor Taizong was about to carry out a major sacrifice to the gods of
Mount Tai and therefore would not have time for military action, launched a major attack against Tang's vassal, the
Qilibi Khan Ashina Simo, whom Emperor Taizong had created the khan of a reestablished Eastern Tujue in 639. Ashina Simo could not resist, and withdrew within the Great Wall to Shuo Prefecture (roughly modern
Shuozhou,
Shanxi). Emperor Taizong launched armies, commanded by five generals, including Li Shiji, to aid Eastern Tujue. Around the new year 641, Li Shiji engaged Xueyantuo forces, under the command of Yi'nan's son Dadu (), at Nuozhen River (, flowing through modern
Baotou,
Inner Mongolia), defeating Xueyantuo forces and forcing them to flee. (Based on comments that Li Shiji made in 644 while advocating a campaign against
Goguryeo, it appeared that Li Shiji wanted to advance further to try to destroy Xueyantuo, but Emperor Taizong, at the urging of
Wei Zheng, ordered him to stop.) Li Shiji subsequently returned to Chang'an to serve as minister of defense. In 643, when Emperor Taizong commissioned the
Portraits at Lingyan Pavilion to commemorate the 24 great contributors to Tang rule, Li Shiji's was one of the portraits commissioned. In spring of that year, when Emperor Taizong's son Li You () the Prince of Qi, angry at his secretary general Quan Wanji (), killed Quan and then declared a rebellion, Emperor Taizong sent Li Shiji to attack Li You, although even before Li Shiji's forces arrived, Li You's subordinates captured him. Subsequently, in summer 643, when
Li Chengqian the Crown Prince, was revealed to have plotted to overthrow Emperor Taizong, as he was fearful that Emperor Taizong would replace him with his brother
Li Tai the Prince of Wei, Emperor Taizong had Li Shiji, along with other key officials Zhangsun Wuji,
Fang Xuanling,
Xiao Yu, as well as officials in charge of the supreme court, the legislative bureau, and the examination bureau, investigate. They confirmed Li Chengqian's guilt. Emperor Taizong thus deposed Li Chengqian and, believing that Li Tai's machinations were responsible for Li Chengqian's downfall, also demoted Li Tai and exiled them both, creating Li Zhi crown prince instead. Li Shiji was given the additional title as the new crown prince's head of household, and was also given a newly created title of
Tong Zhongshu Menxia Sanpin (), which title designated him as a
chancellor de facto. Historical accounts indicated that at one point, when Li Shiji was suddenly ill, medical books indicated that ashes from beards could benefit him, and therefore Emperor Taizong cut off his own beard and burned it to mix it with the medicine. After Li Shiji grew better, he bowed to thank Emperor Taizong—so greatly that he bled from his forehead by pounding on the floor—and Emperor Taizong responded, "I did so for the empire, not for you. You do not need to thank me." Further, on one occasion, when Li Shiji was attending an imperial feast, Emperor Taizong stated: "I am selecting, among the great achievers, one that I can entrust an orphan [(i.e., the Crown Prince)] to, and no one is more suitable than you are. You did not turn your back on Li Mi, and I know that you will not turn your back on me." Li Shiji was so thankful that he wept and bit his finger so hard that he bled. Also at that feast, when Li Shiji became drunk and fell asleep, Emperor Taizong took off his own imperial robe to cover Li Shiji. In spring 644, when the Tang emissary to Goguryeo, Xiangli Xuanjiang (), returned from Goguryeo, indicating that the
Yŏn Kaesomun, the Goguryeo general who then controlled the political scene there, was unwilling to stop his attacks against
Silla, then a Tang vassal, Li Shiji advocated an attack against Goguryeo, and Emperor Taizong agreed, despite opposition by other officials, including
Chu Suiliang. Emperor Taizong, after several months of preparations, launched a two-pronged attack against Goguryeo in winter 644, with Li Shiji in charge of the land army containing 60,000 soldiers, heading toward
Liaodong Peninsula, and with
Zhang Liang in charge of the navy numbering 40,000 soldiers, heading directly toward the Goguryeo capital
Pyongyang. Emperor Taizong himself trailed them. In spring 645, Li Shiji reached You Prefecture (, roughly modern
Beijing), and then headed into Goguryeo territory. Together with
Li Daozong, he captured Gaemo (, in modern
Fushun,
Liaoning), and then put the important city of Liaodong/Yodong (, in modern
Liaoyang,
Liaoning) under siege. After Emperor Taizong himself arrived, Liaodong fell. Tang forces then continued heading southeast, toward
Yalu River, putting Ansi (, in modern
Anshan,
Liaoning) under siege. When a major Goguryeo army, commanded by the generals
Go Yeonsu () and
Go Hyezin () arrived, Emperor Taizong had Li Shiji command 15,000 men to serve as decoy, and when Goguryeo forces attacked Li Shiji, Zhangsun Wuji attacked them from behind with 11,000 men, and Li Shiji and Zhangsun, as well as Emperor Taizong himself, defeated Goguryeo forces, forcing their surrender. He then considered directly attacking
Pyongyang itself, but Li Shiji believed that if Ansi was not captured first, the general in command of Ansi (a capable general known in Korean popular legends as
Yang Manch'un, although whether that was his real name is unknown), might attack Tang forces from the rear. Emperor Taizong agreed, and therefore put Ansi under siege again. However, the commander at Ansi was a capable defender, and the resolve of the defenders was strengthened when Li Shiji, in anger, declared that after the fall of the city all residents would be slaughtered. In fall 645, unable to capture Ansi, with food supplies running low, Emperor Taizong ordered a withdrawal, with Li Shiji and
Li Daozong serving as rear guard. In 646, with Xueyantuo in internal turmoil due to the cruelty of the
Duomi Khan Bazhuo (Yi'nan's son), Emperor Taizong sent
Li Daozong to launch a major attack on Xueyantuo, defeating Xueyantuo forces. Bazhuo fled, but was then attacked and killed by
Huige, which took over Xueyantuo territory. Xueyantuo's remaining forces supported Yi'nan's nephew Duomozhi as
Yitewushi Khan. Duomozhi offered to submit, but Emperor Taizong, fearful that Xueyantuo might recover and create more trouble later on, sent Li Shiji with an army toward Duomozhi's location. Duomozhi surrendered, and Li attacked the remaining forces unwilling to submit, defeating and capturing them. He delivered Duomozhi to Chang'an, where Emperor Taizong made Duomozhi a general. In 647, Emperor Taizong began yearly raids against Goguryeo, intended to weaken Goguryeo's border regions, in preparation for another future major offensive. For the 647 raids, Li Shiji was in charge of the land prong, while Niu Jinda () was in charge of the sea prong. In summer 649, Emperor Taizong was gravely ill (probably from consuming pills given him by
alchemists), and he, not fully trusting Li Shiji, stated to Li Zhi: He then demoted Li Shiji to the post of the commandant of Die Prefecture (, roughly modern
Gannan Tibetan Autonomous Prefecture,
Gansu). Li Shiji, after receiving the order, departed without hesitation. The modern historian
Bo Yang, commenting on this incident, opined that this showed that, down inside, neither Li Shiji nor Emperor Taizong actually trusted each other, as Li Shiji was too capable for Emperor Taizong's liking. Another explanation is that the Taizong was playing an age-old trick to test Li Shiji's loyalty. While he's alive, he was able to handle Li Shiji; he was afraid that his son would not be able to do so after his death. He intentionally demoted Li Shiji to test his response. If Li Shiji showed any hesitation or unhappiness, he would have been executed and the new emperor would not have to deal with him. If Li Shiji didn't show any emotion about the demotion, the new emperor can promote him to show he liked him so Li Shiji would be loyal to him. This turned out to be a bad move. Years later, when Gaozong tried to make
Wu Zetian () his empress against the opposition of most high officials, Li Shiji decisively put the issue in Wu Zetian's favor by saying that's an internal issue of Gaozong.) Nine days later, Emperor Taizong died and was succeeded by Li Zhi (as Emperor Gaozong). == During Emperor Gaozong's reign ==