Liu Yan (; 715/716 – August 12, 780), courtesy name Shi'an (), was a Chinese economist and politician during the Tang dynasty who served briefly as chancellor during the reign of Emperor Daizong – but who was more known for his reforms in the Tang salt monopoly and food transportation systems, credited with allowing the Tang economy to recover after the disastrous An Lushan Rebellion. In 780, during the reign of Emperor Daizong's son Emperor Dezong, after the chancellor Yang Yan made a series of false accusations against him, he was first demoted and then executed.
Background
Liu Yan was born in 715 or 716. His family was from Cao Prefecture (曹州, in modern Heze, Shandong), and traced its ancestry to Liu Jiao (), a younger brother of Han Dynasty's founder Emperor Gao. His great-great-grandfather Liu Jin () served as a county magistrate during Tang Dynasty's predecessor Sui Dynasty, and his great-grandfather Liu Yu () served as an imperial scholar early in Tang. His grandfather Liu Gong () served as a county magistrate, while his father Liu Zhihui () served as a county secretary general.
During Emperor Xuanzong's reign
When Emperor Xuanzong offered sacrifices at Mount Tai in 725, Liu Yan, then a child, wrote a song and submitted it to Emperor Xuanzong. Emperor Xuanzong was amazed, and he had his chancellor Zhang Shuo test Liu's knowledge. Zhang was also impressed and stated, "This is a sign of fortune for the empire." He made Liu a scribe in the imperial government, at his young age, and Liu became referred to as the "godly child." The honored men all rushed to invite him to their households.
During Emperor Xuanzong's Tianbao era (742–756), Liu became the magistrate of Xia County (夏縣, in modern Yuncheng, Shanxi). Xia County was a key point for transportation of supplies to the Tang capital Chang'an, and it was said that while Liu did not supervise the transportation of supplies through his county in a harsh manner, the supplies were nevertheless always on time. After receiving a recommendation, he was then made the magistrate of Wen County (溫縣, in modern Jiaozuo, Henan). It was said that the people were happy about his governance and made monuments for him. He was later recalled to Chang'an to serve as Shiyushi (), a low-level imperial censor.
During Emperor Suzong's reign
In 755, the general An Lushan rebelled at Fanyang and by 756, the forces of his new state of Yan were approaching Chang'an, forcing Emperor Xuanzong to flee to Chengdu. Liu Yan fled to Xiangyang. Emperor Xuanzong's son and crown prince Li Heng fled to Lingwu instead, where he was declared emperor (as Emperor Suzong), an act that Emperor Xuanzong recognized. Emperor Xuanzong, however, prior to Emperor Suzong's declaration as emperor, had sent another son, Li Lin the Prince of Yong, to Jianling to oversee the Yangtze River region. When Li Lin arrived at Jiangling, he heard that Liu was at Xiangfan and invited him to serve on his staff. Liu declined, however, and wrote a letter to the chancellor Fang Guan, pointing out that at this point, having imperial princes with great powers would simply bring trouble. Emperor Suzong then issued an edict making Liu the tax collector for the Yangtze-Huai River region. When Liu reached Wu Commandery (roughly modern Suzhou, Jiangsu), he heard that Li Lin had rebelled against Emperor Suzong, and therefore met with the surveyor of the region, Li Xiyan (), to confer on how to resist Li Lin. Li Xiyan put Liu in defense of Yuhang Commandery (餘杭, roughly modern Hangzhou, Zhejiang). After Li Xiyan was defeated by Li Lin late in 756, he fled to Yuhang and defended it together with Liu. In 757, after Li Lin was defeated by other Tang generals, he initially considered attacking Yuhang, but after hearing that Liu was defending it, he changed his mind and fled west. (He was eventually captured and killed by another Tang general, Huangfu Shen () Liu, however, did not claim credit for the victory. At a later point, Emperor Suzong recalled him to serve as the governor of Pengyuan Commandery (彭原, roughly modern Qingyang, Gansu). He later served as the prefect of Hua Prefecture (華州, in modern Weinan, Shaanxi), and then the mayor of Henan Municipality (), which encompassed the eastern capital Luoyang. However, as at that time Tang forces were still stalemated against the Yan emperor by that point, Shi Chaoyi (the son of An Lushan's general Shi Siming), and Luoyang was still in Yan hands, Liu's government seat was actually at Changshui (長水, near Luoyang).