An Qingxu
With An Lushan having been assassinated by his own son An Qingxu early in 757, An Qingxu was the new emperor of Yan, and after Tang and Uyghur forces recaptured Chang'an, they recaptured Luoyang as well, forcing An Qingxu to flee to Yecheng. Nine Tang military governors put Yecheng under siege, and during the siege, Pugu continued to serve under Guo. When Shi Siming came to Yecheng's aid in summer 759, however, Tang forces collapsed, which the powerful eunuch Yu Chao'en blamed on Guo. Guo was thus recalled to the capital, and the command of his Shuofang army was transferred to Li Guangbi. The Shuofang soldiers, accustomed to Guo's lenience, were apprehensive of the strict Li Guangbi. The general Zhang Yongji (張用濟) thus planned to expel Li Guangbi and demand Guo's return, but was persuaded not to act by Pugu. When Li Guangbi later found out, he executed Zhang. Pugu was made Li Guangbi's deputy and created the Prince of Da'ning. Meanwhile, by that point, Bayanchur Khan had died and had been succeeded by Yaoluoge Yidijian, as Denli Khan, and so Pugu was honored by Uyghurs as well, as the queen's father. Subsequently, Shi killed An Qingxu and assumed the Yan throne, and then advanced south. Li Guangbi evacuated Luoyang and took up defense position at Heyang (河陽, near Luoyang), subsequently holding off Shi's planned advances toward Chang'an against multiple Yan attacks. In the Heyang campaign, both Pugu and his son Pugu Yang (僕固瑒) had much personal contributions. With Tang forces checking him at Heyang, Shi was not able to advance toward Chang'an for over a year. Pugu Huai'en was subsequently given the military governorship of Shuofang and given the command of the Shuofang troops.