사조의
An Lushan rebelled against the rule of Emperor Xuanzong of Tang in late 755, and Li Huaixian, serving under An, participated in An's campaign to capture Tang's central territories, on which An established a state of Yan as its emperor. In spring 756, Li participated in the campaign led by fellow Yan general Linghu Chao () against the city of Yongqiu, defended by the Tang general Zhang Xun, but the Yan generals were unable to capture Yongqiu and eventually forced to withdraw. He later successively served under the next three Yan emperors – An Lushan's son An Qingxu, An Lushan's major general Shi Siming, and Shi Siming's son Shi Chaoyi. After Shi Chaoyi had succeeded to the Yan throne after assassinating his father Shi Siming in 761, he made Li the mayor of the key city Fanyang. According to the Tang Dynasty historian Ping Zhimei (), whose "Jimen Jiluan" () is no longer extant but is often cited in other works, when Li arrived at Fanyang, Fanyang was in a state of disturbance after various Yan generals in Fanyang had fought and killed each other in street battles in the confusion after Shi Siming's death, and it was Li who put down the disturbance and restored order.