The "troops of the northern quarter" (beifubing 北府兵) were a type of elite troops during the Eastern Jin period 東晉 (317-420). The aim for their creation was to defend the northern border against the Former Qin dynasty 前秦 (351-394), one of the Sixteen Barbarian States 五胡十六國 (300~430) that controlled northern China. In 377, Counsellor-in-chief Xie An 謝安 (320-385) and his nephew Xie Xuan 謝玄 (343-388) suggested to create an elite body of troops. The latter was thereupon appointed General of Establishing Martiality (jianwu jiangjun 建武將軍) and regional inspector (cishi 刺史) of the province of Yanzhou 兗州 and chief commander of all troops north of River Yangtze.
In the provinces of Yanzhou and Xuzhou 徐州, a substantial part of the population consisted of refugees from the north (qiaomin 僑民) who knew the topographical conditions and aspired to return to their homelands. This potential was recognized by Huan Wen 桓溫 (312-373), who suggested to use these people as a reservoir for recruits. He found quite a few competent officers among them, like Liu Laozhi 劉牢之 (d. 402), He Qian 何謙, Zhuge Kan 諸葛侃, Gao Heng 高衡, Liu Gui 劉軌 (d. 404), Tian Luo 田洛, or Sun Wuzhong 孫無終. The seat of the high command was in Jingkou 京口 (today's Zhenjiang 鎮江, Jiangsu), a city called Beifu 北府, literally "northern quarter", during that time.
In 379, the new corps besieged the city of Pengcheng 彭城 (today's Xuzhou 徐州, Jiangsu), but the Former Qin armies advanced to the south and threatened the city of San'a 三阿 (close to modern Gaoyou 高郵, Jiangsu). Under the command of He Qian and Liu Laozhi, the two cities were liberated, and the Qin army threwn back. In the famous battle of River Fei 肥水 in 383, the Northern Quarter Army defeated the Qin and reconquered many regions of what is today Henan and Shandong. Liu Niuzhi even advanced to the city of Yecheng 鄴城 (today's Linzhang 臨漳 close to Hanhan 邯鄲, Hebei).
Command over the Northern Quarter Army was soon given into the hands of Sima Yi 司馬怡, Prince of Qiao 譙. He rebelled in 397, but after his defeat, the command was given back to Liu Laozhi. Yet even Liu, who was critical towards the court, used the beifubing for his own purpose. At least, he supported the Jin court during the rebellion of Sun En 孫恩 (d. 402) in 399, and in 402, he defended the dynasty against the rebellion of Huan Xuan 桓玄 (369-404), before he decided to defect to the rebel. Huan Xuan swallowed the Northern Quarter Army, barring a contingent, out of which the commanders Liu Yu 劉裕 (363-422), Liu Yi 劉毅 (d. 412), and He Wuji 何無忌 (d. 410) built up a new force which eventually defeated Huan Xuan. Liu Yu in the end overthrew the Jin and founded the Liu-Song dynasty 劉宋 (420-479).