Originally with a different name and located about 1k north of its present location, legend says it was founded by Kobo Daishi in 811.
It belongs to the Shingon sect and the main deity is Yakushi Nyorai, supposedly carved by Kukai himself.
Historical documents say it was built in 1598 by order of the Lord of the province, Hachisuka Iemasa, as an ekiroji, roadside temple, to provide lodgings for travelers and pilgrims. He ordered 8 ekiroji to be built and while he may well have had some altruistic motives it seems they may have been used to spy upon travelers. Prior to this date, the temple was not part of the 88 temple pilgrimage.