The temple was first built in 515 during the Liang dynasty (502-557). It used to lie at the northeast foot of the Purple Mountain, i.e. where the Ming Xiaoling Mausoleum is located, since the Hongwu Emperor of the Ming dynasty (1368-1644) chose the place to be his mausoleum and then the temple was moved to the present place. The temple was named by the Hongwu Emperor himself. It used to be large and covered an area of over 300,000 square metres. Later it was destroyed in warfare during the reign of the Xianfeng Emperor in the Qing dynasty (1644-1911) and rebuilt during the reign of the Tongzhi Emperor. In the temple, except for buddhas and bodhisattvas, Xuanzang and his relics were enshrined and worshipped.