The shumiyuan 樞密院 "Bureau of Military Affairs" was the highest instiution in the military hierarchy of the political system from the Five Dynasties period 五代 (907-960) to the end of the Yuan period 元 (1279-1368). It was headed by a shumishi 樞密使 "Military Affairs Commissioner". The term shumishi was introduced by Emperor Daizong 唐代宗 (r. 762-779) of the Tang dynasty 唐 (618-907) and used for a palace secretary. This post was occupied by eunuchs. Although the institutions was not really regularized, they wielded highest authority and were able to determine the accession to the throne, and the appointment and dismission of chief ministers. The two shumishi ("palace secretaries") and the commanders of the capital Army of Inspired Strategy (shencejun 神策軍) were so powerful that they were called the "four nobles" (sigui 四貴).
The Later Liang dynasty 後梁 (907-923) founded the institution of the Office for the Veneration of Governance (Chongzhengyuan 崇政院), in which state officials were employed that administered important military matters. The first holder of the office of shumishi was Jiang Xuanhui 蔣玄暉 (d. 906), the dynastic founder's trusted minister. The Later Tang dynasty 後唐 (923-936) changed the name of the Chongzhengyuan to shumiyuan, the ancient name of the Palace Secretariat. Its head, the shumishi, assisted the Left Counsellor-in-Chief (zuo zaixiang 左宰相) and was specialized on military affairs. His status was further elevated after the foundation of the Song dynasty 宋 (960-1279). While the Palace Secretariat (zhongshusheng 中書省) was responsible for civilian matters, the Shumiyuan administered military affairs. Both were called the "two offices" (erfu 二府) or the "two places" (erdi 二地), the former the "Western Office" (xifu 西府), the latter the "Eastern Office" (dongfu 東府).
Head of the Bureau of Military Affairs was the Military Affairs Commissioner (shumishi), also called Administrator of the Bureau of Military Affairs (zhi shumiyuan shi 知樞密院事), when the holder of the office was nominally holding another position. His deputy was called Vice Military Affairs Commissioner (shumi fushi 樞密副使) or Administrator of the Bureau of Military Affairs (tongzhi shumiyuan shi 同知樞密院事, when he nominally held another post). The notaries of the bureau were called qianshu shumiyuan shi 簽書樞密院事, and vice notaries tong qianshu shumiyuan shi 同簽書樞密院事. Between 1078 and 1089 the offices of the commissioner and the vice commissioner were called zheng zhangguan 正長官 and fu zhangguan 副長官.
Towards the end of the Northern Song period 北宋 (960-1126) numerous high state officials were bestowed the honorific title of Military Affairs Commissioner. The position was often held concurrently by the Counsellor-in-chief.
After the defeat by the Jurchens in 1126 and the foundation of the Southern Song 南宋 (1127-1279), the Bureau of Military Affairs was reinvigorated, and the office of shumishi was elevated above that of zhi shumiyuan shi. It was common to appoint a civilian official with the post of Military Affairs Commissioner, following the concept of premature of the civilian realm over the military realm. The Counsellor-in-chief often acted concurrently as Military Affairs Commissioner (shumishi and zhi shumiyuan shi), but it was also common that the Vice Commissioner acted concurrently as Participant in Determining Governmental Matters (can zhizheng shi 參知政事).
The Bureau of Military Affairs was divided into six departments (fang 房) that managed affairs according to the traditional division of the Six Ministries (liubu 六部), namely military, personnel, finance, rites, justice and works. The departments were headed by a Recipient of Edicts (chengzhi 承旨, later called Chief Recipient of Edicts du chengzhi 都承旨), and each department by one or two Vice Repicipents of Edicts (fu chengzhi 副承旨). The number of departments was gradually increased. At the beginning of the Southern Song period there were already more than twenty departments that were in 1127 reduced to the traditional six, and one for miscellaneous matters.
When the Khitans founded the Liao dynasty 遼 (907-1125) in the northern part of China, they adopted many parts of the the political system of the Five Dynasties. The first Military Affairs Commissioner was the defector Li Song 李崧 (d. 948). He was responsible for the administration of the Chinese military units, while those of the Khitan federation remained in the hands of the Khitan princes. It was therefore also called "Southern" or "Chinese" Military Affairs Bureau (nan shumiyuan 南樞密院, Han shumiyuan 漢樞密院). Emperor Shizong 遼世宗 (r. 947-950) founded a Bureau of Military Affairs for the Khitan people that was divided into a northern and a southern department. The northern department administered military matters, the southern department civilian matters.
The Jurchens in 1123 similary founded a Bureau of Military Affairs to administer the surrendered Khitan and Chinese military units. Two years later Emperor Taizong 金太宗 (r. 1123-1134) founded the Chief Military Command (du yuanshuai fu 都元帥府). Prince Hailing 海陵王 (r. 1149-1160) later renamed this institution shumiyuan. The traditionalist Emperor Zhangzong 金章宗 (r. 1189-1208) preferred the older name in 1206, but in 1208 chose the term shumiyuan again.
The Mongols also adopted this institution. The post of shumishi was normally held by the heir apparent, but in fact left vacant, while the Bureau was guided by the zhi shumiyuan shi. In the beginning of his uprising against the Mongol Yuan dynasty, Zhu Yuanzhang 朱元璋 (Emperor Taizu 明太祖, r. 1368-1398), founder of the Ming dynasty 明 (1368-1644), created temporary Bureaus of Military Affairs, but he decided to abolish this term in 1361, and to replace it with that of Chief Military Command (da dudu fu 大都督府).