太武帝
In 448, Liu Jun was made the governor of the equally important Xu Province (徐州, modern northern Jiangsu and northern Anhui), with its capital at Pengcheng, and it was there that he was involved in a major war between Liu Song and Northern Wei. In 450, with Emperor Wen's northern advances not only repelled by Emperor Taiwu of Northern Wei, but with Northern Wei troops under Emperor Taiwu attacking south in retaliation, Northern Wei troops quickly reached Pengcheng. Liu Jun's uncle Liu Yigong () the Prince of Jiangxia, the commander of the northern troops, wanted to abandon Pengcheng, at the suggestion of Zhang Chang (), Liu Jun insisted on defending Pengcheng, and Liu Yigong gave up his plan to flee. Emperor Taiwu, after diplomatic parlaying at Pengcheng, continued advancing south, all the way to the Yangtze River, before withdrawing in 451. Despite holding Pengcheng, Liu Jun was slightly demoted after the war. (During the war, at the instigation of Liu Jun, his older brother Liu Shao the Crown Prince, and He Shangzhi (), Emperor Wen put his brother Liu Yikang, the former prime minister who had been deposed in 440, to death.) In 452, Liu Jun was sent to be the governor of South Yan Province (南兗州, modern central Jiangsu), and then of Jiang Province (江州, modern Jiangxi and Fujian).