The Confucian temple in the Ancient City of Pingyao, Shanxi Province, was first built in the early years of the Zhenguan era (CE 627-649) of the Tang ( CE 618-907) Dynasty, i.e., during the reign of Emperor Taizong, considered as one of the greatest, if not the greatest, Chinese emperor. The original, modest temple was not built as a memorial temple, but rather, was the family temple of Confucius himself.
The present-day memorial temple complex, which is vast, has been damaged and destroyed over the years but was restored and enlarged roughly to its present format during the middle of the 12th century CE. The memorial temple complex, though dedicated to Confucius from its inception, has not always been called the Confucian Temple. In earlier times it had different titles, among these, that of Dacheng Palace. Under that title, the temple complex was rebuilt in the 3rd Dading Year (CE 1163) of the Jin (CE 1115-1234) Dynasty, i.e., during the reign (CE 1161-1189) of Emperor Shizong. After the complex was renamed the Confucian Temple (better known today as Pingyao Confucian Temple), its main hall was given the name of Dacheng Palace. Pingyao Confucian Temple is China's oldest preserved Confucian temple. Those parts of the temple complex which stem from the reconstruction in CE 1163 are the only examples of Jin Dynasty Confucian-temple architecture to be found throughout all of China. Moreover, the temple complex boasts 87 sculptures of Confucius and his disciples, the largest grouping of such sculptures in any Confucian temple complex anywhere in the world.
Throughout most of its history, Pingyao Confucian Temple was the home of the local school. With the abolition of the old Chinese examination system that had been set up during the final years of the reign (CE 1875-1908) of Emperor Guangxu during the Qing (CE 1644-1911) Dynasty, the old local school hierarchy was also abolished. Thus the local school at Pingyao Confucian Temple became the Industrial School of Pingyao County.
In 1923, a group of local businessmen and merchants contributed funds to build Pingyao Lizhi Middle School at the temple. The head of the county, Guo Xueqian, inscribed the new middle school's name on a stele that hung over the entrance to the school. After the emergence of the People's Republic of China, the school was placed under the authority of the state and renamed simply "Pingyao Middle School". It was moved from Pingyao Confucian Temple to a location in Chayuan Street in Pingyao. In 1950, Pingyao Middle School fusioned with Taiyue Middle School and the new, larger school was re-located back to Pingyao Confucian Temple.
Most of the architecture of Pingyao Confucian Temple has been preserved in its Jin Dynasty state, i.e., from its CE 1163 restoration state, also under the government of the PRC. Jiuxing Gate, the Western knowledge teaching facility and the provincial livestock office were dismantled, however. In the late 1950s, a new teaching facility was incorporated into Pingyao Middle School, while the Chaoshan Classical Learning Academy as well as Jingyi Pavilion and Zunjing Pavilion were demolished. Still, much remains of the original school buildings at Pingyao Confucian Temple, just as much of the temple complex dating back to the restoration in CE 1165 remains.
In December 1997, the Ancient City of Pingyao – with, among its many preservation-worthy attractions, the Pingyao Confucian Temple – was officially inscribed as a UNESCO World Heritage Site. It had already been granted special protection by the state government of China as a cultural heritage site. Following the UNESCO World Heritage Site recognition, steps were taken to open Pingyao Confucian Temple to the public while preserving the temple complex from excessive and uncontrolled traffic. Thus Pingyao Confucian Temple was formally opened to the public in 2004.