Shangdang Commandery or Shangdang Prefecture (simplified Chinese: 上党郡; traditional Chinese: 上黨郡; pinyin: Shăngdăng Jùn) was an administrative subdivision of ancient China from the time of the Spring and Autumn period (771–403 BCE). Consisting of a number of districts or Zhōu (州), the prefecture covered roughly the area of modern-day Changzhi City in south east Shanxi Province.
Ancient Chinese sources describe Shangdang as an “upland location in the mountains”. The east and south east areas included the Taihang Mountains on the borders of Hebei and Henan Provinces. In the south west lay Mount Wangwu and the Zhongtiao Mountains. To the west were the Taiyue Mountains (太岳山) with Mount Wuyun (五云山) to the north. King Wuling of Zhao (r. 325–299 BCE) is reported to have said to his son: “Zhao’s territory encompasses Changshan Commandery and Shangdang Commandery. To the east lies the State of Yan bordering Donghu lands. In the West there is Loufang Commandery (楼烦郡) and the Han/Qin border.”
The earliest written record of Shangdang is towards the end of the Spring and Autumn period (771–426 BCE) in connection with the State of Jin. At the time of Duke Ping of Jin (r. 557–532 BCE), official Xie Hu (解狐) appointed Xing Boliu (邢伯柳) as Provincial Governor of Jin’s Shangdang Region.
After the Partition of Jin by the states of Wei, Zhao and Han in 403 BCE, each one occupied a portion of Shangdang Prefecture with their respective capitals located in the territory. The area became the front line in the conflict that followed between these three states given its strategic position. Officials responsible for defending these three frontier prefectures were given the title Shŏu (守 literally guardian) and addressed by the honorific title Tai Shŏu (太守) which in time came to mean provincial governor.
By 265 BCE only seven warring states remained. In Shangdang, Han possessed the northern districts of Yi (仪州) and Qin (沁州) as well as half of Lu (潞) and the southern Ze (泽) districts with the other half held by Zhao and Wei.
Han territory within Shangdang was the first to suffer hardship at the hands of the State of Qin because of its location on the border with Qin. From the time of King Huiwen of Qin (r. 338–311BCE), Qin’s power grew and the state expanded eastwards across the Yellow River. By the time of King Zhaoxiang of Qin’s reign (306–250 BCE) Qin already effectively controlled the entire western part of Shangdang Prefecture. In 262 Qin attacked Han’s Shangdang Prefecture whereupon records show: “A Han official Feng Ting (冯亭) arrived as an emissary to King Xiaocheng of Zhao and said: ‘Our state cannot defend Shangdang, it has been overrun by Qin. Han wants peace with Zhao and does not desire occupation by Qin. 17 of our cities are willing to pay homage to Zhao, Great King, help our government and people.’ King Xiaocheng was exultant and sent troops to Shangdang.” 
As a result, Han’s Shangdang Prefecture thereafter extended the entire length of the western border of the Shangdang Region. Zhao’s control over Shangdang at this early stage in the Warring States period covered Niè (涅) (the northwest of modern-day Wuxiang County), Túnliú (屯留) (the south of modern-day Tunliu County), Zhǎngzĭ (长子) (the south west of modern-day Zhangzi County, Chángpíng (长平) and Xuànshì (泫氏) (both in modern-day Gaoping City) along with Duānshì (端氏) (east of modern-day Qinshui County). This borderline lay north of the Lu District (潞州) with the Nie River (涅水) rising in the north west then flowing south into the turbid waters of the upper Zhang River (漳水). Thereafter the river flowed through the Chang Ping Pass (长平关) into the Lu District before arriving first at Gaoping (高平) then joining up with the Qin River (沁水). All of the conflicts between Han, Zhao and Wei occurred in this area, predominantly in the Túnliú, Niè and Zhǎngzĭ areas with territory frequently changing ownership. For example Zhangzi changed hands at least three times. During the Spring and Autumn period, some scholars suggest that Zhao Xiangzi (襄子) “rushed to Zhangzi” thereafter gaining control of the area for Zhao. Later on, in 370 BCE, Zhao attacked the State of Zheng and thereafter Han, retaking Changzi and showing that by this time Han had retaken control of the area. In 359 BCE, Zheng, by then a Han vassal retook Túnliú, Niè and Zhǎngzĭ. A decade later in 349 BCE Zhao seized territory belonging to Jin in the area of modern-day Qinshui County, Shanxi showing that once more it had returned to Han ownership.
Using the nomenclature of Tang dynasty administrative divisions, Han controlled the whole of Yi District (沁州), the western part of Lu District (潞州) and a small part of the east of Jin District (晋州). Zhao possessed Yi District (仪州) and the larger eastern part of Lu District. Shangdang also contained the Zhao capital Handan. The Battle of Changping which broke the power of Zhao and left Qin the major power in China took place in Shangdang between 262 and 260 BCE.
After Qin Shi Huang’s 221 BCE unification of China Shangdang became one of the 36 Qin prefectures with control over Changzhi. During the Western Han Dynasty (206 BCE–8 CE) Shangdang possessed 14 counties with a total population of 337,766 people divided between 73,798 households (户hù). In the following Eastern Han dynasty the number of counties decreased to 13 whilst the population dropped to 127, 430 people split amongst 26,222 households.
During the Three Kingdoms Period (220–280 CE) the Shangdang seat of government moved to the north of modern-day Changzhi City. By the time of the Western Jin (265–316) the area had been reduced to ten counties with a steep drop in the number of households to only 12,000. The government again moved eastwards to Lu County (潞县) to the north of modern-day Lucheng, Changzhi.
At the time of the Sixteen Kingdoms (304–439 CE) Shangdang was home in succession to the territories of the Former Zhao, the Former Qin, the Western Yan, the Northern Wei and the Northern Zhou all of whom moved the seat of government until it finally returned to Huguan Town (壶关城) in modern-day Huguan County. In 578 CE, the first year of Emperor Xuan of Northern Zhou the Shangdang region became part of Lu Prefecture (潞州), an area to the south of modern-day Xiangyuan County.
After the establishment of the Sui dynasty (581–618 CE) Huguan County was abolished and replaced by Shangdang County (上党县). The Shangdang regional (上党郡) seat of government moved to the county, taking responsibility for 10 counties and 125,057 households.
In the Tang dynasty (618–907 CE) Shangdang Prefecture again became Lu Prefecture ending the use of the name although successive generations still governed Shangdang County. Only in 1529 CE during the reign of the Ming Jiajing Emperor did Shangdang County become Changzhi County and the former name cease to officially exist. Shangdang continued to be used as a name for the location since during the Yuan dynasty records show that Liu Futong (刘福通) led an uprising which crossed the Taihang Mountains and burned Shangdang.
The first battle between the Communists and the Kuomintang after World War II, the Shangdang Campaign, was fought in the region of Shangdang.