In spring 820, Emperor Xianzong died and was succeeded by his son
Emperor Muzong. It was said that the very same day that Emperor Muzong took the throne, he summoned Duan Wenchang, along with two scholars that attended to Emperor Muzong's studies while he was
Crown Prince, Xue Fang () and Ding Gongzhu (), for a meeting. When Emperor Muzong initially wanted to make Xue and Ding chancellors, they declined, and instead, Duan was made
Zhongshu Shilang (), the deputy head of the legislative bureau (), and
de facto chancellor with the title
Tong Zhongshu Menxia Pingzhangshi (), along with
Xiao Mian. While serving as chancellor with Xiao, both Xiao and Duan were blamed for a major policy misstep that cost the imperial government its control over the region north of the
Yellow River. Both he and Xiao thought that the realm had been permanently pacified after Emperor Xianzong's campaigns against warlords, which destroyed many warlords and caused others to agree to follow imperial orders. He and Xiao submitted a proposal that secret orders be sent to each army, ordering them to reduce armies by forced attrition—such that each army was required to reduce its size by 8% each year by desertions or death. As Emperor Muzong, new to the throne, was spent much of his time in drinking and feasting, he did not see the problems with this proposal and approved it. The soldiers removed from army ranks as a result gathered as bandits as a result, and later, when Lulong (盧龍, headquartered in modern
Beijing) and Chengde (成德, headquartered in modern
Shijiazhuang,
Hebei) Circuits rebelled under the leadership of
Zhu Kerong and
Wang Tingcou respectively in 821 (by which time Xiao was no longer chancellor), the former soldiers joined Lulong and Chengde forces in droves, and as they were experienced soldiers and the soldiers that the imperial armies were forced to gather quickly in response were inexperienced, the Lulong and Chengde forces eventually prevailed over imperial forces despite a major numerical disadvantage—with Lulong and Chengde having less than 20,000 soldiers combined and the imperial forces numbering 150,000. In spring 821, it was said that then-military governor of Xichuan,
Wang Bo, was making many attempts in official circles to become chancellor, including bribing the powerful
eunuchs. Duan also was trying to affect the situation on Wang's behalf. Xiao opposed Wang's ascension, and when Emperor Muzong would not listen to Xiao, Xiao resigned. Shortly thereafter, Duan also offered to resign, and he was made the military governor of Xichuan, while Wang was kept at the capital
Chang'an to serve as the minister of justice and director of salt and iron monopolies. He continued to carry the
Tong Zhongshu Menxia Pingzhangshi title as an honorary title. Shortly after Duan was sent to Xichuan, a major scandal broke over high-level officials' influence over the
imperial examination results that year. Both Duan and the imperial scholar
Li Shen had submitted a list of examinees that they hoped would be passed to Qian Hui (), one of the officials in charge of the examinations that season, but once the results were published, the examinees that Duan and Li Shen recommended did not pass, while those who passed included the several relatives of other officials—
Zheng Tan's brother
Zheng Lang;
Pei Du's son Pei Zhuan ();
Li Zongmin's son-in-law Su Chao (); and Yang Yinshi (), brother to the other official in charge of the examinations that year, Yang Rushi (). Duan complained to Emperor Muzong that the examinations that year were not fair. When Emperor Muzong consulted imperial scholars, several imperial scholars who were political enemies of Li Zongmin, including
Li Deyu,
Yuan Zhen, and Li Shen, all agreed with Duan. Emperor Muzong thus ordered a reexamination, while demoting Qian, Li Zongmin, and Yang Rushi, along with 10 examinees who passed based on perceived influence. When Qian's friends subsequently suggested that he submit Duan's and Li Shen's letters trying to influence the examinations to the emperor to show that they were the ones trying to influence results, Qian, who believed that revealing these private letters was inappropriate, burned them. (This was considered a precipitating event to a partisan struggle among Tang officials later known as the
Niu-Li Factional Struggles.) Meanwhile, because Duan was familiar with the customs of the Xichuan people, it was said that he governed with lenience and decisiveness, and that the non-
Han people around the circuit respected and feared him. In 822, when
Nanzhao attacked Tang territory, Duan sent an emissary and was able to persuade Nanzhao forces to withdraw. == During Emperor Jingzong's and Emperor Wenzong's reigns ==