Liu Rengui (劉仁軌) (601/602Liu Rengui's biography in vol.84 of Old Book of Tang recorded that he was 84 (by East Asian reckoning) when he died; his biography in vol.108 of New Book of Tang recorded that he was 85 (by East Asian reckoning) whe he died. – March 2, 685[垂拱元年]春,正月,.....戊辰,文昌左相、同凤阁鸾台三品乐城文献公刘仁轨薨。) Zizhi Tongjian, vol.203), courtesy name Zhengze (正則), formally Duke Wenxian of Lecheng (樂城文獻公), was a Chinese military general and politician during the Tang dynasty, serving as chancellor during the reign of Emperor Gaozong that was dominated by Empress Wu, and the subsequent regency of Empress Dowager Wu over his sons Emperor Zhongzong and Emperor Ruizong. He was known for his military prowess, particularly displayed in the conquest of Baekje, as well as political skills that allowed him to maintain good relationships with colleagues and the strong-willed Empress Wu.

Background Liu Rengui was born in 601 or 602, during the reign of Emperor Wen of Sui. He was from what would later be Bian Prefecture (汴州, roughly modern Kaifeng, Henan). It was said that he was respectful and studious in his youth, but in the disturbances that resulted in the Sui dynasty's downfall in 619, he was unable to spend much time in studying and was forced to flee the wars from time to time, and he would practice his calligraphy by writing on dirt. Early during the reign of the founder of the succeeding Tang dynasty, Emperor Gaozu, one of Emperor Gaozu's generals, Ren Gui (), who was in charge of the modern Henan region, had drafted a report to Emperor Gaozu, when, for reasons unstated in historical records, Liu Rengui had an opportunity to read it. Liu was able to improve on the report by making several simple character changes, and this surprised Ren, who then recommended him as the military advisor to the prefect of Xi Prefecture (息州, roughly modern Xinyang, Henan), and later as the sheriff of Chencang County (陳倉, in modern Baoji, Shaanxi).

During Emperor Taizong's reign Sometime prior to 640 but during the reign of Emperor Gaozu's successor Emperor Taizong, there was an occasion when a military officer, Lu Ning (), who, by virtue of his office, was higher ranked than Liu Rengui (fourth or fifth rank, compared to Liu's ninth rank), was accused of crimes and held in custody at the county jail in Chencang. He, proud of his rank, repeatedly insulted and cursed at Liu. Liu, in anger, battered Lu to death with a cane. When this was reported to Emperor Taizong, Emperor Taizong, in anger, ordered that Liu be executed, but as he was pondering how a lowly ranked sheriff would dare to kill a highly ranked military officer, and so had Liu, prior to execution, delivered to the capital Chang'an for him to personally examine him. When he asked Liu the reason he killed Lu, Liu calmly, without appearance of fear, stated, "Lu insulted me and shamed me in front of the people I govern, and I got so angry that I battered him to death." The chancellor Wei Zheng, who happened to be present, spoke on Liu's behalf, arguing that a reason for Sui's downfall was that the people had no respect for local officials and did not hesitate from resisting them. Emperor Taizong withdrew his order to execute Liu and further promoted him to be the secretary general of Yueyang County (櫟陽, in modern Xi'an, Shaanxi), close to the capital.

In 640, when Emperor Taizong was about to go on a hunt in Tong Prefecture (同州, roughly modern Weinan, Shaanxi), Liu submitted a petition pointing out that it was harvest time and that the farmers would be greatly interfered with by a hunt, particularly since a good number of them would have to be conscripted to fix the roads. He asked that Emperor Taizong delay his hunt by 10 days. Emperor Taizong agreed, and praised Liu for his petition. He soon promoted Liu to be the magistrate of Xin'an County. Eventually, he was promoted to the post of imperial attendant.

During Emperor Gaozong's reign

Campaign against Baekje It appeared that Liu Rengui remained at the post of imperial attendant for at least a decade, after Emperor Taizong's death in 649 and succession by his son Emperor Gaozong. In 656, he was involved in the inquiry into one of Emperor Gaozong's most trusted officials, the chancellor Li Yifu, as Li was accused of being enamored with a beautiful prisoner, a Lady Chunyu, and getting the secretary general of the supreme court, Bi Zhengyi () to improperly release her so that he could take her as a concubine. When the chief judge of the supreme court, Duan Baoxuan () realized this, he reported this to Emperor Gaozong, and Emperor Gaozong put Liu in charge of the investigation. During the investigation, Li, wanting to avoid further scrutiny, forced Bi to commit suicide, and the interrogation was aborted. Still, Liu's investigation drew hatred from Li.

In 659, Liu was made the prefect of Qing Prefecture (青州, roughly modern Weifang, Shandong), at Li's instigation. In 660, as Emperor Gaozong was launching a major campaign against Goguryeo, Liu was in charge of supplying the army through sea shipping, but the ships that he was in charge of met a major storm, and a large number of the ships were lost. Li, hearing this, sent the imperial investigator Yuan Yishi () to Qing Prefecture, hoping to intimidate Liu into committing suicide, but Liu refused. Yuan put Liu in chains and returned to Chang'an to submit his report. Li insisted to Emperor Gaozong that Liu be put to death, but Emperor Gaozong pointed out that Liu could not be held responsible for the storm, instead reducing him to commoner rank and having him join the army in that status.

Meanwhile, the general Su Dingfang had destroyed Goguryeo's ally Baekje in 660, left his assistant Liu Renyuan () in charge of the former Baekje capital Sabi, and then withdrew. Su's mistreatment of the Baekje people, however, caused much resentment toward Tang forces, and after Su's departure, the Buddhist monk Dochim/Daochen () and the Baekje general Buyeo Boksin/Fuyu Fuxin rose in resistance to Tang forces, with Juryu/Zhouliu (주류/周留, in modern Seocheon County, South Chungcheong) as their headquarters. They also welcomed back the Baekje prince Buyeo Pung/Fuyu Feng back from Japan, where he had served as a hostage-to-be-king, and their forces were strengthened. They put Sabi, defended by Liu Renyuan, under siege. Emperor Gaozong put Liu Rengui in command of an army that another general, Wang Wendu (), who had recently died, would have commanded, and had him aid Liu Renyuan. Liu Rengui was pleased at the news, and was said to have immediately leapt up and stated, "Heaven is giving glory and wealth to this old man!" He then, after confidently requesting the imperial calendar and the names of the imperial ancestors (in order to promulgate to the Baekje people for naming taboo purposes), departed for Baekje. Fighting the Baekje resistance forces in conjunction with forces from Tang's ally Silla, he was able to force them to lift the siege on Sabi. However, he and Liu Renyuan still had too few forces, particularly after Silla forces withdrew after suffering defeats, so for a time Liu Renyuan and Liu Rengui held defensive position.

Meanwhile, Su, who had been attacking Gogureyo and putting its capital Pyongyang under siege, was forced to withdraw in spring 662 after the general Pang Xiaotai () was defeated and killed by Goguryeo forces. Emperor Gaozong issued an edict, ordering Liu Renyuan and Liu Rengui to abandon Sabi and march to Silla—and then, at the option of Silla's King Munmu (Kim Beopmin/Jin Famin), remain to help defend Silla or return to Tang. The soldiers largely wanted to accept these orders, but Liu Rengui pointed out if they abandoned Sabi, Baekje would be reestablished and would not be able to be defeated. However, believing that LIu Renyuan and Liu Rengui would surely abandon Sabi, Buyeo Pung and Buyeo Boksin (who had by now assassinated Dochim and taken over the rest of the army) were becoming overly confident and not taking precautions. Liu Rengui caught them by surprise and captured a number of cities they held, including a strip of territory that allowed Silla forces to supply Sabi with food. Liu Renyuan reported this to Emperor Gaozong and requested reinforcements, and Emperor Gaozong sent 7,000 men, as well as Buyeo Pung's brother Buyeo Yung/Fuyu Long, who was familiar with the territory.

Meanwhile, Buyeo Pung and Buyeo Boksin were beginning to suspect each other as well, and Buyeo Pung killed Buyeo Boksin in an ambush and then sought aid from Goguryeo and Japan. At Liu Rengui's insistence, in 663, the Tang/Silla forces headed directly for the Baekje headquarters at Juryu, defeating joint Baekje/Japanese forces. Buyeo Pung fled to Goguryeo, and the rest of the Baekje resistance forces surrendered, ending the Baekje resistance movement. Emperor Gaozong recalled Liu Renyuan and left Liu Rengui in charge of Baekje's former territory. It was said that Liu Rengui was effective in comforting the Baekje people and restoring social order after years of warfare had rendered the region in waste. He was also credited with treating two Baekje generals, Heukchi Sangji/Heichi Changzhi and Sataek Sangyeo/Shazha Xiangru () with kindness, after they had participated in Baekje's resistance movement, pointing out that they were compelled to do so after Su mistreated the Baekje people—and he was able to receive their allegiance, allowing him to, with their serving as his forward commanders, defeat the last Baekje general holding out, Ji Susin/Chi Shouxin (). After Liu Renyuan returned to Chang'an, he endorsed Liu Rengui's abilities, and Emperor Gaozong gave Liu Rengui honors, including a house at the capital.

After the campaign against Baekje In 664, Liu Rengui, by now carrying the higher rank of commandant, submitted a petition pointing out that the soldiers stationed at Baekje was facing much difficulties, after having been away from home for five years, and should be greatly rewarded. Emperor Gaozong partially agreed with Liu Rengui's pleas and sent Liu Renyuan to relieve him with new reinforcements, but Liu Rengui did not believe this to be the right course of action further, believing that the army should remain to prepare for the next campaign against Goguryeo, and Emperor Gaozong permitted Liu Rengui to remain at Baekje. However, the following year (665), as Emperor Gaozong with Empress Wu was preparing for a grand ceremony to make sacrifices to Heaven and Earth at Mount Tai, Liu Rengui returned to Tang along with emissaries from Silla, Tamna, Japan, and the former Baekje, to attend to Emperor Gaozong and Empress Wu during the ceremony. Emperor Gaozong and Empress Wu was pleased by these emissaries' presence, and promoted Liu Rengui to the post of imperial censor, keeping him in the imperial administration. He also gave Liu Rengui the designation Zhi Zhengshi (), making him a de facto chancellor at the suggestion of Empress Wu.