Liu Yan was a descendant of Liu Yu, who was Prince of Lu in the early Han dynasty. Because his branch of the Liu family was powerful, and because he proved himself to be an able statesman, he quickly rose through the ranks of the court. The highest post he reached was that of Minister of Ceremonies, or person responsible for ceremonies related to the emperor. During the reign of Emperor Ling, the central court became a politically dangerous place, which Liu Yan wanted to distance himself from. An adviser of his, Dong Fu, suggested requesting to be the Governor of Yi Province, at that time considered a backward and distant province of the Han Empire. Liu Yan took the advice, and with his private army set off for his new post in 188. After arriving in Yi Province, Liu Yan was confronted with his first crisis. Ma Xiang and Zhao Zhi started a rebellion in the region, claiming to be part of the Yellow Turban Rebellion. Liu Yan enlisted the help of powerful local families to raise an army and put down the rebellion. Once firmly in control of the region, he plotted to gain independence from the central Han government. The first step in his plan was to send Zhang Lu and Zhang Xiu to attack the forces of the official Han governor of Hanzhong, Su Gu and take over his territory. Zhang Lu first killed Zhang Xiu, and after absorbing the latter's armies he successfully managed to kill Su Gu and take control of the territory, which created an independent buffer state between Liu Yan's Yi Province and the Han central government. His next step in gaining control of the region was to rein in the power of the local families, who had their own wealth and large private armies. He executed the leaders of over 10 families, but another powerful family leader Jia Long banded together with others and rebelled. Although the armies of the families were powerful, Liu Yan's forces eventually prevailed. The next threat was from the Qiang people, who attacked Liu Yan's capital of Mianzhu. However, Liu Yan's forces were able to successfully defend their territory from being ravaged. In 194, when Li Jue and Guo Si gained control of Chang'an after Dong Zhuo's death, three of Liu Yan's sons were in Chang'an serving in various government posts. Liu Yan joined forces with Han Sui and Ma Teng in an attempt to attack the capital and seize it. With the help of his sons in the city, the armies attacked, but were defeated. In the hasty retreat, Liu Fan and Liu Dan were captured by Li Jue's forces as they tried to flee Chang'an, and were tortured and killed. Liu Zhang, however, barely managed to escape and join up with his father, who returned once again to Yi Province. In summer of the same year, Liu Yan's residence in Mianzhu was struck by lightning and burnt down, forcing him to relocate the provincial capital to Chengdu. Soon afterward, his third son Liu Mao died from illness. It is said that the grief caused by the loss of three sons caused him to develop an illness on his back, which would eventually cause his death later in the year. His death left his fourth and youngest son Liu Zhang in control of Yi Province.
*Liu Fan, served as General of the Household of the Left, killed by Li Jue
*Liu Dan, served as Imperial Clerk Preparer of Documents, killed by Li Jue
*Liu Mao, served as Senior Major, died from illness
*Liu Zhang, inherited Liu Yan's position as Governor of Yi Province, lost Yi province to Liu Bei, joined Liu Bei, defected to Sun Quan, Died 2 years later.
Daughters-in-law:
*Lady Wu, Liu Mao's wife, married Liu Bei after her husband's death, became known as Empress Mu
*Lady Fei, Liu Zhang's wife, Fei Guan 's younger sister
*Lady Cui, Cui Yan's younger sister
In ''Romance of the Three Kingdoms''
In the 14th-century historical novel Romance of the Three Kingdoms, Liu Yan was the governor of You Province in northern China during the events of the Yellow Turban Rebellion. He met Liu Bei, who rallied an army of volunteers to help him fight the Yellow Turban rebels. In Chen Shou's Records of the Three Kingdoms, however, there is no record of Liu Yan assuming governorship of You Province.