Very little is known about Liu Ji's family background, other than his family was from Jiangling (江陵, in modern Jingzhou, Hubei). It is not known when he was born. Late in Sui Dynasty, when a descendant of the imperial house of Liang Dynasty, Xiao Xi, rose in 617 against the rule of Emperor Yang near Jiangling, claiming to be rebuilding Liang Dynasty, Liu became his subject and served under him as the deputy head of the legislative bureau of government. In or before 621, Xiao sent Liu to the modern Guangdong region to persuade cities to submit to Liang rule, and 50 some cities did so. However, before Liu could return to Jiangling, Jiangling came under the attack of the Tang Dynasty general Li Xiaogong, and Xiao was forced to surrender. Liu thus submitted to Tang rule with those 50 odd cities. Emperor Gaozu of Tang made him the secretary general at Nankang Prefecture (南康州, roughly modern Zhaoqing, Guangdong).
