Niu–Li factional strife

The Niu–Li factional strife () was an ongoing contention at the court of the mid-to late Tang dynasty. It is largely viewed to have started during the reign of Emperor Muzong, circa 821, but having its seeds in the events of his father Emperor Xianzong—between two court factions later to be referred to by Chinese historians as the Niu Faction (牛黨), named after Niu Sengru, which was largely viewed as a faction of officials from humble origins and who passed the imperial examinations to get into government; and the Li Faction (李黨), named after Li Deyu, which was largely viewed as a faction of officials from aristocratic origins. The two factions struggled for decades at court, during the reigns of Emperor Muzong and his sons Emperor Jingzong, Emperor Wenzong, and Emperor Wuzong. The struggles are viewed as having ended at the start of the reign of Emperor Wuzong's successor and Emperor Muzong's younger brother Emperor Xuānzong, in 846. Emperor Xuanzong despised Li Deyu and systematically demoted officials related to Li Deyu, leading to the complete defeat of the Li Faction.

Background 
Traditionally, the seeds of the Niu–Li factional strife were seen to have been sown in 808, when Emperor Xianzong held a special imperial examination for the examinees to give honest criticism of government. The officials in charge of the examination, Wei Guanzhi and Yang Yuling (楊於陵), selected three examinees who gave blunt criticism—Niu Sengru, Huangfu Shi (皇甫湜), and Li Zongmin—for top marks. However, Chancellor Li Jifu was stung by the criticism they provided and viewed it as a personal attack against him. Li Jifu tearfully complained to Emperor Xianzong that the reviewers of the scores that Wei and Yang gave the imperial scholars - Pei Ji and Wang Ya — had conflicts of interest, as Huangfu was Wang's nephew. As a result of his accusations, Pei, Wang, Yang, and Wei were each demoted, with Wei initially demoted to be the prefect of Guo Prefecture (果州, in modern Nanchong, Sichuan), and then further moved to be the prefect of Ba Prefecture (巴州, in modern Bazhong, Sichuan). Niu, Huangfu, and Li Zongmin were not exiled, but were said in the Zizhi Tongjian to be effectively stalled in their careers, forcing them to find governmental positions themselves under regional governors. Despite this, Li Jifu's son Li Deyu viewed the insult on his father to be too great to bear, and thereafter an enmity developed between Li Deyu and those he viewed as having criticized his father unfairly.

During Emperor Muzong's reign 
After Emperor Xianzong's death in 820, Emperor Xianzong's son Emperor Muzong became emperor. Subsequently, the imperial examinations of 821 became, according to the Song dynasty historian Sima Guang, the triggering event for what became the Niu–Li factional strife.

As of 821, Li Deyu was serving as an imperial scholar (翰林學士, Hanlin Xueshi), and both he and fellow imperial scholar Yuan Zhen were resentful of Li Zongmin, who had become a Zhongshu Sheren (中書舍人)—a mid-level official at the legislative bureau of government (中書省, Zhongshu Sheng). Meanwhile, Li Zongmin's junior colleague at the legislative bureau, Yang Rushi (楊汝士), and the deputy minister of rites (禮部侍郎, Libu Shilang) Qian Hui (錢徽), were in charge of overseeing the imperial examinations. The military governor (Jiedushi) Duan Wenchang (a former chancellor) and the imperial scholar Li Shen both made secret pleas to Qian for certain examinees. However, when the results were announced, the examinees that Duan and Li Shen recommended were not given passing results, while among those passing the examinations were Zheng Lang, the brother of the examination bureau (門下省, Menxia Sheng) official Zheng Tan; Pei Zhuan (裴譔) the son of the military governor Pei Du (also a former chancellor); Li Zongmin's son-in-law Su Chao (蘇巢); and Yang Rushi's brother Yang Yinshi (楊殷士). This caused a popular uproar, and Duan submitted a report accusing Yang Rushi and Qian of being unfair. When Emperor Muzong requested opinions from the imperial scholars, Li Deyu, Yuan, and Li Shen all agreed with Duan's opinion. Emperor Muzong thus ordered Li Zongmin's colleague Wang Qi (王起) to conduct a re-examination, while demoting Qian, Li Zongmin, and Yang Rushi to be prefectural prefects and deposing 10 of the examinees selected by Qian and Yang Rushi.

Meanwhile, by 823, Niu Sengru was serving as the deputy minister of census (戶部侍郎, Hubu Shilang), and was much respected by Emperor Muzong. After the death of the military governor-turned-chancellor Han Hong, Emperor Muzong discovered that virtually all the officials in the imperial administration had received bribes from Han, who wanted to ingratiate them, but that Niu had refused the bribe. Emperor Muzong, impressed by Niu, named him chancellor in 823. At that time, Li Deyu, who had become the governor (觀察使, Guanchashi) of Zhexi Circuit (浙西, headquartered in modern Zhenjiang, Jiangsu), was considered a potential chancellor candidate as well, and as he was passed over in this selection and would eventually not be promoted for a stretch of eight years. He came to believe that it was the chancellor Li Fengji (who was later considered a Niu-party leader as well) who recommended Niu for chancellorship in order to reject him. He thus resented Niu and Li Fengji even more.

Meanwhile, Li Shen, still an imperial scholar at this point, was also respected by Emperor Muzong, and he often criticized both Li Fengji and the powerful eunuch Wang Shoucheng, with whom Li Fengji had a good relationship. Li Fengji, in order to alienate Emperor Muzong from Li Shen, intentionally recommended Li Shen as deputy chief imperial censor (御史中丞, Yushi Zhongcheng) in order to create a conflict between Li Shen and Han Yu, the mayor of the capital municipality Jingzhao Municipality (京兆, i.e., the Chang'an region)—over the matter of whether Han, as the mayor, was required by tradition to pay respect to the imperial censors. As Han also carried the honorary title of chief imperial censor (御史大夫, Yushi Daifu), Li Fengji had ruled that he need not, but Li Shen nevertheless demanded it, causing him and Han to exchange harshly worded communiques to each other. With the dispute between Li Shen and Han flaring into the open, Li Fengji recommended demotions for both, and Han was made the deputy minister of defense (兵部侍郎, Bingbu Shilang) while Li Shen was made the governor of Jiangxi Circuit (江西, headquartered in modern Nanchang, Jiangxi). Subsequently, Emperor Muzong realized that this conflict had been manufactured by Li Fengji, and kept Li Shen in the capital as the deputy minister of census.

During Emperor Jingzong's reign 
In 824, Emperor Muzong died and was succeeded by his son Emperor Jingzong. In the aftermath of Emperor Jingzong's ascension, Li Fengji had Wang Shoucheng informed Emperor Jingzong that it was because of Li Fengji's support that Emperor Muzong made him crown prince—and that Li Shen and the former chancellor Du Yuanying had both supported Emperor Muzong's younger brother Li Cong (李悰) the Prince of Shen. Believing Wang's assertions, Emperor Jingzong exiled Li Shen to be the military advisor to the prefect of Chao Prefecture (潮州, in modern Chaozhou, Guangdong), and demoted two imperial scholars that Li Shen had recommended, Pang Yan (龐嚴) and Jiang Fang (蔣防), to be prefects of two other distant prefectures. Li Fengji's associates subsequently often asked that Li Shen be put to death, and Emperor Jingzong initially agreed. After the junior imperial scholar Wei Chuhou submitted a petition in Li Shen's defense, Emperor Jingzong reviewed the palace archives and found that both Du and Li Shen (as well as Pei Du) had also supported him as crown prince, Emperor Jingzong destroyed all the reports accusing Li Shen of crimes, although he did not recall Li Shen to Chang'an.

Meanwhile, in 825, Niu Sengru was still serving as chancellor, but he was feeling powerless to stop what he saw as Emperor Jingzong's frivolousness and poor governance. He asked to be sent out of the capital. Emperor Jingzong made him the military governor of Wuchang Circuit (武昌, headquartered in modern Ezhou, Hubei). Also, that year after Emperor Jingzong declared a general pardon, Li Fengji submitted a proposed edict announcing the general pardon that would permit those exiled officials who had previously received a movement toward Chang'an be given another one, but not stating anything with regard to those exiled officials who had never received a previous movement toward Chang'an. Wei pointed out that this wording was intended by Li Fengji to prevent Li Shen's movement toward Chang'an. At Wei's suggestion, the edict was revised, allowing Li Shen to be moved to Jiang Prefecture (江州, in modern Jiujiang, Jiangxi) to serve as its secretary general.

In 826, Emperor Jingzong summoned Pei (viewed by some later historians as a Li Party leader) back to the capital and made him chancellor again. Trying to prevent Pei from gaining Emperor Jingzong's trust, Li Fengji's associates spread rumors that Pei was prophesied to be emperor, but Emperor Jingzong was not moved by these rumors.

During Emperor Wenzong's reign

Before the Ganlu Incident 
In 826, Emperor Jingzong was assassinated by his polo players, who had resented him for his impulsively harsh treatment of them. After a faction of eunuchs had tried to make his uncle Li Wu the Prince of Jiāng emperor, another faction of eunuchs, led by Wang Shoucheng, defeated the faction supporting Li Wu and made Emperor Jingzong's younger brother Li Han the Prince of Jiàng (note different tone) emperor (as Emperor Wenzong).

Early in Emperor Wenzong's reign, Pei Du and Wei Chuhou were the leading chancellors. In 828, after Wei's death, Lu Sui succeeded Wei. In 829, Emperor Wenzong, under Pei's recommendation, recalled Li Deyu to Chang'an to serve as the deputy minister of defense, and Pei further recommended Li Deyu for chancellorship. However, Li Zongmin, then serving as deputy minister of civil service affairs (吏部侍郎, Libu Shilang), was said to prevail over Li Deyu because of support from the eunuchs, and Li Zongmin became chancellor, instead of Li Deyu. Subsequently, in 830, at Li Zongmin's recommendation, Niu was recalled from Wuchang and also made chancellor. It was said that Niu and Li Zongmin, working together, began to eject Li Deyu's partisans out of the imperial government. This included Pei, whom Li Zongmin had made the military governor of Shannan East Circuit (山南東道, headquartered in modern Xiangfan, Hubei), even though Li Zongmin had previously served on Pei's staff during Pei's first term as chancellor.

Li Deyu himself was sent to Xichuan Circuit (西川, headquartered in modern Chengdu, Sichuan), which had recently been devastated by a Nanzhao incursion, as its military governor. It was said that Li Deyu distinguished himself there by building up the defenses, rebuilding the economy, and training the soldiers. In 831, Xidamou (悉怛謀), the Tufan officer in charge of Wei Prefecture (維州, in modern Ngawa Tibetan and Qiang Autonomous Prefecture, Sichuan), surrendered Wei Prefecture, which Tufan had captured from Tang decades earlier, to him. Li Deyu advocated accepting the surrender and using Wei Prefecture as a launch pad for a major campaign against Tufan.  Niu opposed, arguing that this was a violation of the peace treaty between Tang and Tufan and that, should a war start, Tufan forces could reach Chang'an easily. Emperor Wenzong accepted his argument and ordered that Li Deyu return Wei Prefecture, as well as Xidamou and his soldiers, to Tufan. Tufan had Xidamou and his soldiers massacred. The massacre brought much popular sentiment against Niu, and was commonly viewed at the time to be the result of the conflict between Niu/Li Zongmin and Li Deyu. With Emperor Wenzong regretting the decision, Niu repeatedly offered to resign. Emperor Wenzong was constantly asking the chancellors   when true peace would come to the realm. Niu saw true peace as impossible to achieve within a short time and viewed Emperor Wenzong as overly eager. Around the new year 833, Emperor Wenzong made Niu the military governor of Huainan Circuit (淮南, headquartered in modern Yangzhou, Jiangsu).  (The Xidamou incident has been one of the most controversial incidents in the study of Tang history, with various historians taking different views on the issue of whether Niu had a partisan motive in opposing Li Deyu's proposal to accept Xidamou's surrender and to further attack Tufan, and whether, ultimately, Niu or Li Deyu was correct.)

Li Deyu was recalled to Chang'an to serve as the minister of defense (兵部尚書, Bingbu Shangshu), and it was commonly expected that he would next become chancellor, despite Li Zongmin's opposition. Li Zongmin's associate Du Cong suggested an attempt to make peace with Li Deyu—as Du felt that Li Deyu's resentment toward the Niu Faction officials partially stemmed from his jealousy of their having passed the imperial examinations, whereas he was perceived as having risen due to his family background. Du suggested that Li Zongmin recommend Li Deyu to be in charge of the imperial examinations to satisfy him. Li Zongmin rejected this idea, but initially accepted Du's alternative idea of recommending Li Deyu to be chief imperial censor. When Li Zongmin sent Du to visit Li Deyu to communicate this proposal, Li Deyu was receptive and thankful. However, after Li Zongmin consulted another associate, Yang Yuqing (楊虞卿) (Yang Rushi's cousin), Yang Yuqing opposed the idea, and Li Zongmin never actually recommended Li Deyu to be chief imperial censor.

Meanwhile, Yang Yuqing, Yang Rushi, Yang Yuqing's brother Yang Han'gong (楊漢工), Zhang Yuanfu (張元夫), and Xiao Huan (蕭澣) were perceived by Emperor Wenzong to be overly eager in their partisanship, and he began to dislike them. After he made Li Deyu chancellor in 833, Li Deyu used Emperor Wenzong's dislike for these officials to begin ejecting Niu Faction officials from the government. Li Zongmin responded by having Zheng Tan, who was then imperial scholar, removed from his post as imperial scholar—but Emperor Wenzong reacted by promoting Zheng to be the chief imperial censor without consulting Li Zongmin, which caused Li Zongmin to be angry and fearful. Soon thereafter, Li Zongmin himself was sent out to Shannan West Circuit (山南西道, headquartered in modern Hanzhong, Shaanxi), to serve as its military governor.

Meanwhile, though, Emperor Wenzong began to become close to a physician that Wang Shoucheng recommended, Zheng Zhu. Subsequently, at Zheng Zhu's recommendation, Li Zhongyan, a former official who had been exiled due to crimes, also became a close associate of the emperor. Li Zongyan was thereafter made a professor at the imperial university over Li Deyu's strenuous objections; they caused a rift between Li Deyu and Emperor Wenzong. Meanwhile, Wang, Li Zongyan, and Zheng Zhu, wanting to divert power from Li Deyu, had Li Zongmin recalled from Shannan West Circuit to serve again as chancellor, while sending Li Deyu to Shannan West to serve as his military governor. Li Deyu met with Emperor Wenzong and asked to stay at Chang'an, and initially Emperor Wenzong agreed, making him the minister of defense again. However, after Li Zongmin objected that Li Deyu should not be allowed to stay or go based on his own desire, Li Deyu was instead sent back to Zhexi Circuit, which was renamed Zhenhai Circuit, to serve as its military governor.

In 835, the officials Wang Fan (王璠) and Li Han (李漢) accused Li Deyu of having associated with Emperor Wenzong's brother Li Cou the Prince of Zhang, hoping to support Li Cou as emperor to replace Emperor Wenzong. Emperor Wenzong, in anger, summoned a tribunal of chancellors to judge Li Deyu. Lu Sui spoke in defense of Li Deyu, and he was relieved of his duties and exiled to Yuan Prefecture (袁州, in modern Yichun, Jiangxi) to serve as its secretary general. Lu himself suffered the consequences of being sent out to Zhenhai to serve as its military governor and, contrary to the regular official movements at the time, he was not allowed to meet with Emperor Wenzong before his departure. Soon thereafter, Zheng Zhu's associate Jia Su was made chancellor.

Meanwhile, there were rumors at Chang'an that Zheng Zhu was using alchemy to make pills intended to give Emperor Wenzong immortality—and that such pills required the use of infants' hearts and livers. This caused much panic in the public, and Zheng, who had long disliked Yang Yuqing, accused his family members of spreading the rumors. Yang was arrested, and LI Zongmin tried unsuccessfully to intercede for Yang, causing Emperor Wenzong to be so angry that he loudly ordered Li Zongmin to leave his presence. Zheng, who had also by this point resented Li Zongmin for Li Zongmin's refusal to allow him to take a title as an official of either the legislative or examination bureau, also attacked Li Zongmin. Emperor Wenzong exiled Li Zongmin to serve as the prefect of Ming Prefecture (明州, in modern Ningbo, Zhejiang). Zheng further revealed that Li Zongmin had flattered the eunuch Yang Chenghe (楊承和) and the female official Song Ruoxian (宋若憲) in order to become chancellor, Li Zongmin was further exiled to be the census official of Chao Prefecture (潮州, in modern Chaozhou, Guangdong). Li Zhongyan (whose name had been changed to Li Xun by this point) and Zheng subsequently had Li Zongmin's associates ejected from the imperial government. Further, they also accused any official that they disliked of being an associate of the "two Lis" (Li Deyu and Li Zongmin), and had them ejected from the imperial government as well—effectively leaving both Niu and Li Parties out in the cold, with Zheng Zhu and Li Xun in control of the government.

After the Ganlu Incident 
Meanwhile, Emperor Wenzong, weary of the powerful eunuchs holding command of the imperial Shence Armies (神策軍) and power within the palace, had been secretly plotting with Zheng Zhu, Li Xun, and their associates, to slaughter the eunuchs. To this end, in winter 835, Zheng was made the military governor of Fengxiang Circuit (鳳翔, headquartered in modern Baoji, Shaanxi) with the intent that he get his soldiers ready for such an event. When Li Xun, intending on taking the entire credit for himself, prematurely launched the attack on December 14, 835, the eunuchs, led by Qiu Shiliang and Yu Hongzhi (魚弘志), defeated Li Xun and his associates instead, leading to a general slaughter of many of the imperial administration officials by the Shence Armies, including the deaths of LI Xun, Zheng, the chancellors Wang Ya, Jia Su, Shu Yuanyu, and other participants in Li Xun's plot, including Wang Fan, Luo Liyan (羅立言), Guo Xingyu (郭行餘), and Li Xiaoben (李孝本). This incident became known as the Ganlu Incident, and after this, Emperor Wenzong became, in effect, submissive to the eunuchs.

In the aftermaths of the Ganlu Incident, Li Shi and Zheng Tan were made chancellors, and while most of the power remained in the leading eunuchs' hands, it was said because of a severely worded petition filed by the military governor Liu Congjian objecting to the deaths of Wang Ya and Jia, the powerful eunuchs began to show some restraint, allowing Emperor Wenzong and the chancellors to have some ability to govern. Meanwhile, Li Zongmin was moved closer to the capital, to be the military advisor to the prefect of Heng Prefecture (modern Hengyang in Hunan). Henceforth, the officials accused of being partisans of Li Zongmin and Li Deyu were beginning to be allowed to move toward the capital.

Qiu, however, resented Li Shi for his attempts to reassert imperial authority, and in 838 made an unsuccessful attempt to have him assassinated. Li Shi, in the aftermath, became apprehensive and offered to resign, and he was sent to Jingnan Circuit (荊南, headquartered in modern Jingzhou, Hubei) to serve as its military governor. At the same time, Yang Yuling's son Yang Sifu and Li Jue, both viewed as Niu Faction leaders, became chancellors. When Yang Sifu subsequently tried to have Li Zongmin re-promoted, fellow chancellors Zheng Tan and Chen Yixing, both of whom were viewed as Li Party leaders, opposed, and starting from this point, it was said that every policy discussion in the imperial administration would have partisan undertones. After a major verbal argument between the chancellors in 839, Yang offered to resign; instead, Chen and Zheng were relieved of their chancellor posts.

In 839, with Emperor Wenzong being seriously ill, his favorite concubine Consort Yang recommended his brother Li Rong the Prince of An as crown prince—a move that was later suspected to be supported by Yang Sifu, who appeared to be her nephew. Li Jue, however, was opposed. Instead, Emperor Wenzong created Emperor Jingzong's youngest son Li Chengmei the Prince of Chen crown prince. However, when Emperor Wenzong became even more ill in 840, Chou and Yu, wanting to use this opportunity to control the imperial succession, had an edict issued in Emperor Wenzong's name creating another brother of his, Li Chan the Prince of Ying, crown prince instead. Emperor Wenzong soon died, and even before Li Chan took the throne formally, Consort Yang, Li Rong, and Li Chengmei were ordered to commit suicide, and many eunuchs and musicians who were personally close to Emperor Wenzong were either killed or exiled. Li Chan then took the throne (as Emperor Wuzong).

During Emperor Wuzong's reign 
As Emperor Wuzong knew that it was not the wishes of chancellors Yang Sifu and Li Jue that he become emperor, he had both Yang Sifu and Li Jue relieved of their chancellorships soon after he took the throne. At the recommendation of the eunuch Yang Qinyi (楊欽義), whom Li Deyu had befriended while he was serving as the military governor of Huainan and Yang Qinyi served as the eunuch monitor of the Huainan army, Emperor Wuzong recalled Li Deyu to serve as chancellor and entrusted him with the affairs of the state. Yang Sifu and Li Jue were sent out of the capital, to serve as the governors of Hunan Circuit (湖南, headquartered in modern Changsha, Hunan) and Gui District (桂管, headquartered in modern Guilin, Guangxi), respectfully, while such associates as Pei Yizhi (裴夷直) and Li Zhongmin (李中敏) were also demoted.

In 841, with further accusations by Qiu Shiliang against Yang Sifu and Li Jue, as well as the eunuchs Liu Hongyi (劉弘逸) and Xue Jileng (薛季稜), whom Emperor Wenzong had trusted, he came to believe that Yang and Liu had intended to support Li Rong and Li Jue and Xue had intended to support Li Chengmei. The Emperor ordered Liu and Xue to commit suicide. He also sent eunuch messengers to Hunan and Gui to order the deaths of Yang and Li Jue. With Du Cong pointing out to Li Deyu that he should not encourage Emperor Wuzong to be in the mode of killing officials, Li Deyu, along with fellow chancellors Cui Gong, Cui Dan, and Chen Yixing, interceded on Yang's and Li Jue's behalf, and after much pleading from them, Yang, Li Jue, as well as Pei, were demoted further, but their lives were spared. However, later in the year, Li Deyu used the excuse of a major flood in Shannan East, where Niu Sengru was then serving as military governor, to have Niu relieved of his command and given the honorary post as senior advisor to the Crown Prince.

Meanwhile, Li Deyu continued to have the full confidence of Emperor Wuzong, and his repeated suggestions, during the crisis where Tang's erstwhile ally Huigu collapsed under Xiajiasi attacks and Huigu forces subsequently raided Tang borders, were accepted by Emperor Wuzong. Eventually, under Li Deyu's oversight, Tang forces were able to defeat the marauding Huigu forces.

In 843, Li Deyu, apparently intending to use the incident to further launch attacks against the Niu Faction officials, requested a review of the incident where Xidamou surrendered Wei Prefecture but then was returned to Tufan to be killed. In response, Emperor Wuzong  honored Xidamou with a general title posthumously.

Later in 843, Liu Congjian died. At his death, he tried to pass the command of Zhaoyi Circuit to his adopted son Liu Zhen (his biological nephew), and the officials at court had different opinions about whether a campaign should be launched against Liu Zhen or whether he should be allowed to assume command. Under Li Deyu's advocacy, Emperor Wuzong ordered a general campaign against Liu Zhen, and in 844, under pressure from imperial troops, Liu Zhen's subordinate Guo Yi (郭誼) killed Liu Zhen and surrendered.

Emperor Wuzong rewarded Li Deyu with great honors in light of the victory over Liu Zhen, including the title of the Duke of Zhao. However, at the same time, Li Deyu was drawing resentment over his domination of the court scene—and was particularly despised in his having Emperor Wuzong issue a posthumous edict condemning the relatives of Wang Yai, Jia Su, and Li Xun, who had fled to Zhaoyi and been protected by Liu Congjian but whom Guo slaughtered after killing Liu Zhen. Further, still resenting Niu and Li Zongmin, Li Deyu accused  them of having corroborated with Liu Congjian and Liu Zhen, despite the lack of any evidence. Li Deyu went as far as inducing Liu Zhen's secretary Zheng Qing (鄭慶) into making the statement that whenever Liu Congjian received letters from Niu and Li Zongmin, he would read them and then burn them. Further, he had Lü Shu (呂述) the vice mayor of Luoyang, where Niu was at the time, make the accusation that when Niu heard of Liu Zhen's defeat, he sighed. Li Deyu relayed these accusations to Emperor Wuzong, and, in anger, he exiled both Niu and Li Zongmin. Further, in 845, Li Deyu had Li Shen, who was then the military governor of Huainan, falsely accused the county magistrate Wu Xiang (吳湘)—the nephew of an official that Li Deyu had deeply resented, Wu Wuling (吳武陵)—of forcibly marrying a commoner's daughter. Despite objections by many officials, under Li Deyu's advocacy, Emperor Wuzong ordered Wu Xiang's execution without further review.

It was said that by this point, Li Deyu had been so affected by the power he wielded that he could no longer govern impartially. In 845, when the junior official Wei Hongzhi (韋弘質) pointed out that chancellors have so much power already that they should not further control the imperial treasury, Li Deyu had Wei demoted, further drawing resentment toward him.

In 846, Emperor Wuzong, afflicted by illnesses caused by alchemists' pills, became seriously ill. The eunuchs secretly decided that Emperor Wuzong's uncle Li Yi the Prince of Guang should be made crown prince, and they issued an edict in his name to such effect. Emperor Wuzong soon died, and Li Yi (whose name was changed to Li Chen) took the throne (as Emperor Xuānzong).

During Emperor Xuānzong's reign 
Emperor Xuānzong had, while an imperial prince, disliked Li Deyu's hold on power. After the ceremony in which he ascended to the throne and in which Li Deyu submitted the formal congratulatory report from the imperial officials on behalf of all of them, Emperor Xuānzong commented to his servants, "Was not the person who was closest to me during the ceremony the Taiwei [(i.e., one of the Three Excellencies and one of Li Deyu's titles)]?  When he was looking at me, all my hairs were raised!" Just seven days after taking the throne, Emperor Xuānzong, to the surprise of the entire imperial administration, sent Li Deyu out of the capital to serve as the military governor of Jingnan Circuit, and also exiled Li Deyu's associates Xue Yuanshang (薛元賞) and Xue Yuanxhang's brother Xue Yuangui (薛元龜). Soon after, Emperor Xuānzong issued an edict permitting the five former Niu Faction chancellors exiled by Emperor Wuzong—Niu Sengru, Li Zongmin, Cui Gong, Yang Sifu, and Li Jue—to be promoted to positions closer to Chang'an, although Li Zongmin died before he could be moved. Emperor Xuānzong also made Li Deyu the defender of Luoyang and removed the honorary chancellor title that he continued to carry as the military governor of Jingnan from him, further showing disapproval.

Meanwhile, Bai Minzhong, who had become trusted by Emperor Xuānzong and been made chancellor, attacked Li Deyu for the offenses he had committed as chancellor, and he was further demoted to be an advisor to the crown prince. As well, people that Li Deyu had disfavored were often being promoted by this point, while people that Li Deyu had favored were demoted. Emperor Xuānzong also reversed the severe regulations against Buddhist monks and nuns that Emperor Wuzong had instituted with Li Deyu's support.

In 847, when Wu Xiang's brother Wu Runa (吳汝納) submitted a petition proclaiming that Wu Xiang was executed even though he had committed no capital crimes and further accusing Li Shen and Li Deyu of conspiring to achieve the unjust result, Emperor Xuānzong ordered an investigation by the Office of the Imperial Censors (御史臺, Yushi Tai). After the investigation, Li Deyu was exiled to Chao Prefecture to serve as the military advisor to its prefect. Emperor Xuānzong also demoted other officials who were considered complicit or negligent in Wu Xiang's death, and posthumously stripped Li Shen's offices. Emperor Xuānzong's dislike for Li Deyu was so intense that when the imperial official Ding Rouli (丁柔立), whom Li Deyu had not favored, submitted a petition to defend Li Deyu, Ding was nevertheless considered an associate of Li Deyu's and demoted to be a county sheriff, while Cui Jia (崔嘏), whose draft of the imperial edict condemning Li Deyu was considered to be insufficiently harsh in its wording, was demoted to be a prefectural prefect. Further, the general Shi Xiong, whom Li Deyu had recommended during the campaign against Liu Zhen, was denied a military governor position when he requested one because of his association with Li Deyu. By this point, the factional struggles between the Niu and Li Factions are considered to have largely come to their end.

Leading figures

Niu Faction 
 Niu Sengru
 Li Zongmin
 Li Fengji
 Yang Rushi
 Yang Sifu
 Li Jue
 Bai Minzhong

Li Faction 
 Pei Du
 Li Deyu
 Zheng Tan
 Chen Yixing
 Li Shen

Notes and references 

Tang dynasty
9th century in China
821
Political party factions in China