[3][4][5] The Shoku Nihongi records that in 741, as the country recovered from a major smallpox epidemic, Emperor Shōmu ordered that a monastery and nunnery be established in every province, the kokubunji (国分寺).
The exact date of this Heian period foundation is uncertain, and traces of a fire lend some credence to temple legend that it was burned down in a battle between the armies of the central government and the forces of the rebel Taira no Masakado in 938 AD.
Many other provincial temples around the country were destroyed during this period, due to a decline in the authority of the central government and rise of competing local warlords.
The layout mirrors that of the Tōdai-ji in Nara, the head temple of the kokubunji system, with the main buildings lined up in a single file from south to north, with the cloister connecting the Middle Gate and the Lecture Hall, and the pagoda located to the southeast of the Kondō.
The three-story pagoda was destroyed by lightning around 1585, which was the year that the local warlord Sanada Masayuki defeated the Tokugawa clan at the Battle of Ueda.
In the Edo Period, the temple was revived with the assistance of the various daimyō of Ueda Domain under the Tokugawa shogunate and a number of buildings were repaired or reconstructed, including the Three-story pagoda.