When Emperor Xuanzong of Tang ascended the throne, Ma Yuanzhi was given command of the Shence Army. During the An Lushan rebellion, 1,000 Shence Army troops under general Wei Boyu were dispatched to assist the embattled central authorities. Boyu subsequently defended the area around Sanmenxia after troops from Tufan had occupied Lintao County. Yu Chao'en was later appointed commander of the Shence Army. In 763, Tubo attacked Chang'an and Emperor Daizong of Tang fled to Sanmenxia. Chao’en's army combined forces with Tang troops in Sanmenxia combined and were collectively referred to as the Shence Army. When Emperor Daizong later returned to the capital, the Shence Army again became one of the Imperial Guard units and gradually increased in strength.
Because pay and conditions for the soldiers of the Shence Army were relatively good, a gradual succession of other imperial guard units gradually joined its ranks. By the time Emperor Dezong of Tang ascended to the throne, the Shence Army had grown to 150,000 troops and was the main military power in both Chang'an and the surrounding Guanzhong Plain. After Zhu Ci's rebellion in 784, command of the Shence Army was handed over to the court eunuchs for whom it became the emperor's primary military tool.
Under the succeeding Emperor Shunzong of Tang, court official Wang Shuwen unsuccessfully tried to wrest control of the Shence Army from the eunuchs, thereafter in the final years of the Tang dynasty the Shence Army became riddled with corruption and its power declined.
Under Emperor Xizong of Tang, the Shence Army was totally routed during the Huang Chao Rebellion.[1] Whilst Emperor Xizong fled to the Xichuan Circuit in modern-day Sichuan, eunuch Tian Lingzi raised a new Shence Army. The formation was disbanded for good in 903 when Zhu Wen, founder of the Later Liang murdered all the palace eunuchs in Chang’an.