Emperor Xuanzong, in his later years, began to lavishly shower favor on his concubine Yang Yuhuan, and conceded a considerable share of his power to Li Linfu and Yang Guozhong, two wicked officials. He himself indulged in sensuous pleasures while subsequently paying listless attention to the running of the state. Thus the Tang ruling class became more and more corrupt, bringing about the disastrous An-Shi Rebellion.
The An-Shi Rebellion refers to the treacherous war unleashed by An Lushan and Shi Siming. While Emperor Xuanzong was on the throne, ten garrisons were set up in important border regions to strengthen defense. The highest official of the garrison was called Jiedushi, entitled to both military command and decision-making in administration and finance, thus playing a crucial role. According to the usual practice of the time, a jiedushi who had accomplished outstanding feats could be transferred to the court to assume the post of Prime Minister.
Li Linfu, while in power, not only tried to force civil officials out of the court, but also took a suspicious attitude towards the Jiedushi in the frontier areas, even framing them. At that time, some of the generals stationed in the border areas were Hu (a term used by the Han to refer to the non-Han nationalities in the northern and northwestern border regions). Li believed that the Hu were insufficiently educated, and should not be elevated to court office. But, in Emperor Xuanzong's presence, he suggested that more Hu should be appointed Jiedushi, and thus Xuanzong followed his counsel and did so.
An Lushan was part Hu. When young, he went into the service of Zhang Gui, Jiedushi of Youzhou (garrisoning the area around present-day Beijing). An was expert at currying favor with his superiors. Even Li Linfu, a man who paid lip-service only but always harbored ulterior motives, offered to put in a good word for An in front of Xuanzong.
The emperor was taken in, believing An capable, and elevated him to the position of jiedushi of Pinglu. Later, the emperor made him concurrently responsible for the garrisons of Fanyang and Hedong, as the Jiedushi of both areas, taking command of180,000 troops, accounting for over one third of all the Tang border forces. But An Lushan, still not satisfied with his power and influence, left no stone unturned to win the emperor's affection and trust, who in turn granted An a dukedom, allowed his concubine Yang Yuhuan to adopt him as a godson, and gave him free access to the inner palace.
An Lushan, after wooing the emperor and Li Linfu to place trust in him, began to secretly expand the army. He elevated Shi Siming, Cai Xide and other valiant officers to key positions, appointing two Han officials Gao Shang and Yan Zhuang as his top advisors, selected 8,000 warriors from soldiers of various ethnic groups in the border regions who had surrendered to him, and formed a crack force. They were storing up grain and fodder and preparing weaponry, anxiously awaiting the death of Emperor Xuanzong in order to stage a rebellion. On the lst day of the 11th month, in 755, An Lushan rose up in Fanyang under the pretext of opposing Yang Guozhong, rallying over 150,000 troops, while professing to have over 200,000. An, together with his rebels, drove south, intending to fight their way into the Central Plains and then Chang'an, to overthrow the Tang Dynasty and to ascend the throne himself During the Tianbao period (742-756), corruption in the court had sharply detracted from the combat effectiveries of its troops. Furthermore, the area was part of An's sphere of influence.
Therefore, after the rebel forces had fought their way over, civil officials and military officers in the 24 counties north of the Yellow River fell into a great panic; some opened the city gate to usher in the rebels, many deserted the city, while others were captured and killed. The rebel forces met hardly any resistance and quickly swept over large stretches of land, bringing disastrous calamity upon the people, and wreaking havoc in the society. An's troops quickly captured Luoyang, an important city in the east, and swarmed towards the east gate to the capital Chang'an, Tongguan Pass. In Luoyang, An Lushan proclaimed himself "Emperor of Great Yan," appointing ministers, dispatching officials, and establishing an oppositional regime.