After the defeat of the combined Baekje and Yamato Japan forces, at the hands of the Silla and Tang China alliance at the Battle of Hakusukinoe in 663, the Yamato court feared an invasion from either or both Tang or Silla. In response, a huge network of shore fortifications was constructed throughout the rest of the 600s, often with the assistance of Baekje engineers, generals and artisans. Unaware of the outbreak of the Silla-Tang War (670–676), the Japanese would continue to build fortifications until 701, even after finding out that Silla was no longer friendly with Tang.[3] The name "kōgoishi" means "stones of divine protection," a name given them by the Meiji period archaeologist Tsuboi Shōgorō, who conjectured that they served as spiritual or practical protection for sacred sites. Scholars after Tsuboi determined that the structures are most likely the remains of practical, military fortifications, and were unlikely to have significant spiritual connections, although much remains unknown about these structures and there is very little contemporary documentary evidence.[4]
Kiyama Castle is located approximately eight kilometers south of the Dazaifu Government Office ruins, overlooking the branch point of the ancient government highway connecting Dazaifu with Higo Province and Chikugo Province. Kiyama Castle surrounds the eastern summit of Mount Kiyama, with fortifications at an elevation of 404 meters. The walls extend for 3.9 kilometers, enclosing an area of about 60 hectares, and three valleys. Most of the walls are earthen ramparts, but the valleys are fortified with stone walls. From the castle it is possible to see Hakata Bay to the north, and the Ariake Sea to the east, with the Serifu Mountains to the west. [5]
Archaeological excavations have confirmed the traces of about 40 buildings, and excavated artifacts include roof tiles, and pottery, and the remains four castle gates: two in the northern part of the castle, and one each in the south and southeast.
Per the Nihon Shoki, the castle was built in fourth year of the reign of Emperor Tenchi, or 665 AD, with construction carried out largely by exiles from Baekje, along with Ōno Castle, and a as-yet unidentified castle in Nagato Province. An entry dated 698 in the Shoku Nihongi mentions repair work undertaken at Kii Castle.[5] It was abandoned and fell into ruins before the end of the Nara period, and was only re-discovered in 1912.