Emperor Wen of Liu Song (; 407 – 16 March 453jiazi day of the 2nd month of the 30th year of the Yuanjia era, per Emperor Wen's biography in Book of Song. The biography also indicated that he was 47 (by East Asian reckoning) when he died. Thus by calculation, his birth year should be 407.), personal name Liu Yilong (), childhood name Che'er (), was the third emperor of the Liu Song dynasty of China. He was the third son of the dynastic founder Emperor Wu (Liu Yu). After his father's death in 422, Liu Yilong's eldest brother Liu Yifu took the throne as Emperor Shao. In 424, a group of officials, believing Emperor Shao to be unfit to be emperor, deposed Emperor Shao and placed Liu Yilong on the throne as Emperor Wen.
In his 29 years of rule, Emperor Wen largely continued the grand plan of his father and some of the land policies of the Jin Dynasty. The period, called the "Yuanjia administration" (), is seen as a period of prosperity and strength, because of the emperor's diligence and ability to find capable and honest officials to serve in his administration. However, Emperor Wen was faulted for making repeated failed attempts to attack rival Northern Wei and using the wrong strategies in doing so, weakening his state toward the end of his rule. In 453, angry that his crown prince Liu Shao was using witchcraft to curse him, he planned to depose Liu Shao; when this plan was leaked, Liu Shao staged a coup and assassinated him, replacing him on the throne, although less than a year later Liu Shao's younger brother Liu Jun (Xiulong) defeated him and took the throne as Emperor Xiaowu.
Early life Liu Yilong was born at Jingkou (, in modern Zhenjiang, Jiangsu) in 407, to Liu Yu and his concubine Hu Dao'an (), as Liu Yu's third son; at that time, Liu Yu was already the paramount general for Jin, and so Liu Yilong was born into a household of power and wealth. For reasons lost to history, Liu Yu put Consort Hu to death in 409. Liu Yilong's maternal grandmother Lady Su was involved in his upbringing, and he was particularly close to her as he grew up. In 410, while the Jin capital Jiankang was under attack by the warlord Lu Xun, Liu Yu had his assistant Liu Cui () accompany the three-year-old Liu Yilong to serve as the defender of Jingkou. In 415, he was created the Duke of Pengcheng. In 417, while Liu Yu was attacking Later Qin, he had Liu Yilong, again assisted by his staff, remain at Pengcheng to serve as the governor of Xu Province (, modern northern Jiangsu and Anhui), to guard his rear. In 418, after Liu Yu conquered Later Qin, Liu Yilong was made the governor of the important Jing Province (荊州, modern Hubei and Hunan), and commander of armed forces of the western empire. Those who served on his staff included Dao Yanzhi (), Zhang Shao (), Wang Tanshou (), Wang Hua (), and Shen Linzi, with Zhang actually in charge of headquarters due to Liu Yilong's young age. After Liu Yu seized the Jin throne in 420, establishing Liu Song (as Emperor Wu), he created a number of his sons princes, and Liu Yilong was created the Prince of Yidu at that time. Around this time, he became known as studious in the Confucian classics and histories, and was also a good calligrapher.
In 424, believing Liu Yilong's older brother Emperor Shao (who had succeeded Emperor Wu after Emperor Wu's death in 422) to be frivolous and incapable of governing the empire, the high-level officials Xu Xianzhi, Fu Liang, and Xie Hui deposed and subsequently killed him, as well as another older brother of Liu Yilong's, Liu Yizhen () the Prince of Luling, since they believed Liu Yizhen to be even less suitable than Emperor Shao. Believing Liu Yilong to be capable and lenient, they offered the throne to Liu Yilong, with Fu personally arriving with other officials at Liu Yilong's headquarters at Jiangling. Liu Yilong's associates, hearing of Emperor Shao's and Liu Yizhen's deaths, were largely suspicious and suggested that he not head east to the capital Jiankang to accept the throne. However, Wang Hua pointed out that the coup leaders were in a collective leadership, and the balance of power ensured that they could not commit treason. Wang Tanshou and Dao also agreed, and Liu Yilong decided to accept the throne, taking the throne later that year as Emperor Wen.
Early reign Initially, Emperor Wen pacified the high-level officials who were involved in deposing Emperor Shao (including not only Xu Xianzhi, Fu Liang, Xie Hui, but also Wang Tanshou's brother Wang Hong and Tan Daoji) by leaving them in power and further giving them higher offices. Indeed, he initially left most affairs of state in the hands of Xu and Fu, but gradually acquainted himself in those matters. He also hinted at disapproval of their actions by recalling the wives and mothers of Emperor Shao and Liu Yizhen to the capital and treating them with honor. He posthumously honored his mother Consort Hu as an empress dowager, and created his wife Princess Yuan Qigui as empress.
In 425, Xu and Fu offered to resign, and Emperor Wen approved and began to handle important matters of state himself. However, Xu's nephew Xu Peizhi () and his associates Cheng and Wang Shaozhi () persuaded him to reconsider, and thereafter he reassumed his post. (While it was not explicitly stated in history, it appeared that Fu then did so as well.) However, Emperor Wen was resentful that Xu, Fu, and Xie had killed his two older brothers, and in late 425 planned to destroy them, particularly at the urging of Wang Hua and the general Kong Ningzi (). He therefore mobilized troops and publicly declared that he was going to attack rival Northern Wei, but was privately preparing to arrest Xu and Fu while engaging in a military campaign against Xie, then the governor of Jing Province. In spring 426, rumors had leaked of such a plan, and so Xie began to prepare for armed resistance. Soon, Emperor Wen publicly issued an edict ordering that Xu, Fu, and Xie be arrested and killed, while issuing a separate edict summoning Xu and Fu to the palace.
Believing that Wang Hong and Tan had not been involved initially in the plot against Emperor Shao, he recalled them to the capital, and put Tan in charge of the army against Xie and Wang Hong in charge of the imperial government. Meanwhile, Xie Hui publicly mourned Xu and Fu and declared that all they did was for the empire, blaming Wang Hong, Wang Tanshou, and Wang Hua for falsely accusing them, and demanding their execution. Xie Hui had a powerful army, but while he thought that several other provincial governors would join him, they refused. He was initially able to defeat Dao's army, but soon Tan arrived, and Xie, fearful of Tan, did not know what to do. Tan quickly attacked him and defeated his fleet, and Xie fled back to Jiangling, and then fled with his brother Xie Dun (), but Xie Dun was so overweight that he could not ride a horse, and so they slowed down and were captured. He was then delivered to Jiankang and executed with Xie Jiao and Xie Dun, along with all of his nephews and major associates, although many of his associates were spared.
Emperor Wen became quickly known for his diligence in governing the state and his frugality, as well as his caring for the welfare of the people. He set up a system where officials, both at the capital and in provinces, were given relatively long office terms, but carefully monitored for their progress. He was particularly attentive to his brothers' ability to govern, offering them much advice while carefully fostering proper experience for them. One of them, Liu Yikang the Prince of Pengcheng, soon became known for his skills at governing Jing Province after replacing Xie, and in 428, Wang Hong, who was fearful of drawing attacks for having been prime minister for too long, offered to resign and give his authority to Liu Yikang. Emperor Wen declined at this point, but did transfer most of Wang Hong's authorities to Liu Yikang in 429. Also in 429, Emperor Wen created his oldest son by Empress Yuan, Liu Shao, crown prince. That year, Emperor Wen's maternal grandmother Lady Su died, and he mourned her greatly, wanting to posthumously create her titles, but because of opposition by the key official Yin Jingren (), he did not do so.
Around this time, Emperor Wen also started preparing for a campaign against rival Northern Wei, seeking to recover several provinces lost to Northern Wei during the reign of Emperor Shao. In spring 430, he put Dao Yanzhi in command of a 50,000-man army to attack Northern Wei. Emperor Taiwu of Northern Wei, when informed by Emperor Wen's messengers that all Emperor Wen was interested in was to recover the provinces south of the Yellow River, retorted angrily that he would withdraw but return in the winter once the Yellow River froze, and that was what he initially did—withdrawing his armies south of the Yellow River to areas north, allowing Liu Song to recover the four key cities of Luoyang, Hulao, Huatai (, in modern Anyang, Hunan), and Qiao'ao (, in modern Liaocheng, Shandong) without a fight. Instead of advancing further north into Northern Wei proper, however, Emperor Wen stopped and placed his troops along the Yellow River, even though he had entered into an alliance with Xia's emperor Helian Ding to conquer and divide Northern Wei. With Emperor Wen's forces immobile, Northern Wei was able to attack Helian Ding and greatly damage Xia (eventually leading to its destruction in 431) absence. Afterwards, Northern Wei prepared to attack the south. In winter 430, Emperor Wen's general Du Ji (), unable to defend Luoyang, abandoned it. Hulao soon also fell. Upon hearing this, Dao retreated, leaving the general Zhu Xiuzhi () defending Huatai alone. In spring 431, Emperor Wen sent Tan north to try to relieve Zhu at Huatai, but with Northern Wei forces cutting Tan's supply route off, Tan was unable to reach Huatai and forced to withdraw as well. Zhu, without support, was soon captured when Huatai fell. Emperor Wen's first attempt to regain the provinces south of the Yellow River had resulted in failure.
In 432, Wang Hong died, and Liu Yikang was, alone, prime minister after that point.
Also in 432, angry over the misgovernance of Liu Daoji () the governor of Yi Province (modern Sichuan and Chongqing), the people of Yi Province rose, under the command of Xu Muzhi (), who changed his name to Sima Feilong () and claimed to be a descendant of the Jin imperial clan. Liu quickly defeated and killed Sima Feilong, but the Buddhist monk Cheng Daoyang () soon rose in succession and claimed to be the real Sima Feilong, threatening Chengdu the capital of Yi Province, and while the general Pei Fangming () was able to repel the siege, Cheng remained a threat for several years, carrying the title of the Prince of Shu. While the campaign was ongoing, Yang Nandang () the ruler of Chouchi, who had been a nominal vassal to both Liu Song and Northern Wei, also attacked and occupied Liang Province (, modern southern Shaanxi) in 433.
Middle reign In spring 434, Emperor Wen's general Xiao Sihua () was able to defeat Yang Nandang's forces and recapture Liang Province. Yang Nandang soon apologized, and not willing to lose a potential ally against Northern Wei, Emperor Wen accepted his apology.
In 435, Feng Hong the emperor of Northern Yan, under constant Northern Wei attack, offered to be a vassal to Liu Song to try to obtain assistance, and Emperor Wen created Feng Hong the Prince of Yan. However, Emperor Wen was unable to provide actual assistance, and Feng Hong evacuated his state and fled to Goguryeo in 436.