quality:corruption, structural:reformatting
Siege of Yecheng

However, the Tang prince Li Chu the Prince of Guangping (the son of Li Heng, who by this point had taken imperial title as Emperor Suzong), with aid from Huige, was able to recapture Chang'an in summer 757 by defeating Yan forces in the Battle of Xiangji Temple. Tang forces under Li Chu and Huige forces then advanced east, toward Luoyang. In winter 757, An put together his forces and sent them, under Yan Zhuang's command, to defend Shan Commandery (陝郡, roughly modern Sanmenxia, Henan). When Yan forces engaged Tang forces, however, they saw that Huige forces were on Tang's side, and, in fear, they collapsed. Yan Zhuang and Zhang Tongru (張通儒) fled back to Luoyang to inform An, and An, after executing some 30 Tang generals who had been captured, abandoned Luoyang and fled north, to Yecheng, which he converted to Ancheng Municipality.

At the time that An arrived at Yecheng, he had only 1,000 infantry soldiers and 300 cavalry soldiers. Soon, however, Yan generals Ashina Chengqing (阿史那承慶), Cai Xide, Tian Chengsi, and Wu Lingxun (武令珣), who had been attacking other Tang cities, headed to Yecheng and coalesced there, allowing An to have over 60,000 soldiers under his disposal and thus regaining some measure of strength. Meanwhile, apprehensive of Shi, he sent Ashina and An Shouzhong (安守忠) to Fanyang to order Shi to contribute troops, but was intending to have Ashina and An Shouzhong take over Shi's command if possible. Instead, Shi arrested Ashina and An Shouzhong and submitted to Tang. Many other cities previously under Yan's control also submitted to Tang, and An Qingxu's territory shrank to just Yecheng and the surrounding area. It was said that An Qingxu became cruel and paranoid in light of these military losses, and that if generals submitted to Tang, he would slaughter their families if they were Han and their tribes if they were non-Han. Meanwhile, believing accusations that Zhang made against Cai, he killed Cai, which further led to dissension among his soldiers, particularly since he then put Cui Qianyou (崔乾祐) in command of his army, and the soldiers resented Cui for his harshness.

By winter 758, the Tang generals Guo Ziyi, Lu Jiong (魯炅), Li Huan (李奐), Xu Shuji (許叔冀), Li Siye, Ji Guangchen (季廣琛), Cui Guangyuan (崔光遠), Dong Qin (董秦), Li Guangbi, and Wang Sili (王思禮), were gathering at Yecheng and putting it under siege. An Qingxu tried to fight out of the siege, but was defeated by Tang forces, and his brother An Qinghe (安慶和) was killed. Meanwhile, with Shi recently having again rebelled against Tang, An sent the general Xue Song to Fanyang to seek aid from Shi, offering the throne to him. Shi thus advanced south toward Yecheng. Meanwhile, Tang forces, under the command of nine generals (with Li Siye having died during the siege), were uncoordinated. On 7 April 759, Shi engaged Tang forces—and, when a storm suddenly arrived, both armies panicked; Shi's forces fled north, and Tang forces fled south, lifting the siege on Yecheng. An Qingxu's forces gathered the food and supplies abandoned by Tang forces, and An thereafter considered, with Sun Xiaozhe (孫孝哲) and Cui, the possibility of refusing Shi, who gathered his troops and again approached Yecheng, admittance. Shi himself was not communicating with An, but was feasting his soldiers and watching Yecheng. Zhang and Gao Shang (高尚) requested permission to meet Shi, and An agreed; Shi gave them gifts and let them return to Yecheng. An, unsure what to do, again offered the throne to Shi, which Shi declined. Shi instead suggested to him that perhaps they could both be emperors of independent, allied states. An, pleased, exited Yecheng and met with Shi to swear to the alliance.