Shuofang (Chinese: 朔方) was an ancient Chinese commandery, situated in the Hetao region in modern-day Inner Mongolia near Baotou. First founded by Emperor Wu of Han in the wake of the successful reconquest of the area from Xiongnu tribes, it was dissolved during the late Eastern Han Dynasty and then reconstituted centuries later during the Northern Wei and Sui periods, before finally being dissolved during the Tang Dynasty.
The term Shuofang, in ancient usage, simply referred to the north; this definition was recorded in dictionaries such as the Erya.
The northward bend of the Yellow River is an area of considerable strategic importance that had been part of the State of Zhao during the early Warring States period. During this period it was called Jiuyuan, and was a commandery. As Zhao gradually weakened, the area fell under Xiongnu control, only to be reconquered during the Qin Dynasty by a large expedition led by the general Meng Tian.
In the chaos of the rebellions that took place during the end of the Qin Dynasty, the Xiongnu once again moved into the area and took control, and retained this area even after the foundation of the Han Dynasty, using it as an important staging post for raiding into northern and northeastern China. It was only during the Han–Xiongnu War launched by Emperor Wu that the Han Dynasty proactively sought to take over the former borderlands of the Qin Dynasty. In 127 BC, an expedition led by Wei Qing defeated the Xiongnu, leading to the foundation of Shuofang Commandery; by 8 BC the commandery had ten constituent counties.
In the spring of 617, Liang Shidu, a former regimental commander from a prominent family of Shuofang commandery on the southern edge of ethe Ordos, seized power from the commandery officials and declared the establishment of the "Liang" state with himself as emperor.