Kuinji Temple was built on the site of the former residence of the Takeda family, who served as shugo (provincial governors) of Wakasa Province. After the completion of Obama Castle in 1641, both the Nochiseyama Castle built by the Takeda on Mt. Nochiseyama and the residence at the base of the mountain were abandoned. When Sakai Tadakatsu (1587–1662) was appointed lord of the Obama domain in 1634, he used the land of the former Takeda residence to found a family memorial temple (bodaiji). Over time, several fires destroyed the original grand halls of Kuinji, but the yakuimon gate remains, serving as an example of Edo-period (1603–1867) architecture. The graveyard behind the main hall, surrounded by earthen walls, still has graves for many of the Sakai family members.
A cave located on the temple grounds is featured in a legend about Happyakubikuni, “the 800-year-old nun.” According to the story, in the seventh century a certain influential man received an invitation to a banquet from a mysterious host. When he arrived, he was shocked to see that mermaid meat was one of the dishes being prepared for the feast. Despite the host’s insistence, the man managed to avoid trying the strange meat, but was pressured into taking some home, where his curious daughter ate it before he could stop her. Because of the mermaid flesh, the woman ceased to age and became immortal. She outlived her family and became a traveling nun, wandering the country for centuries. When she returned to Obama, she entered the cave near Kuinji Temple and was never seen again.