The term kiganjo refers to a Buddhist temple or Shinto shrine at which worshipers pray for favors. If it is a temple, it is referred to as a "kiganji" or a "goganji."
In addition, a temple designated as a kiganji by the Emperor is referred to as a "chokuganji."
People have prayed at Shinto shrines since ancient times. As can be seen in "Azuma Kagami" (The Mirror of the East) and "Taiheiki" (The Record of the Great Peace), many samurai worshipped Shinto Kami during the latter part of the Heian period as a result of Usa Hachiman-gu Shrine becoming the ujigami (ancestral deity) of the Minamoto clan.
After being imported into Japan during the Asuka period, Buddhism came under state control and temples were established by the nation and influential clans. It is this that led to temples becoming places at which to pray for the development of the nation, the prevention of infectious diseases and the health of the country's population.
During the Heian period, belief in Buddhism spread throughout the noble classes, with each clan constructed temples in which to pray for the prosperity of the clan, although some clans had practiced this since the Nara period.
In the Kamakura period, Buddhism spread to the Samurai class, with temples being constructed in which to pray for the prosperity and safety of the head of each territory as well as the entire family, and these eventually became integrated with temples founded to pray for the souls of those family members who died in battle.
Buddhism disseminated to the common people during the Muromachi period and it became commonplace to pray at temples throughout the country, with prayers being written down and offered to the temple.
During the Edo period, travel became more widespread and, although until then people only visited nearby temples and shrines, it became the practice for people to visit distant temples and shrines and say various prayers in different locations such as Zenko-ji Temple and the Shikoku Pilgrimage.
Pre-modern prayers were more like an agreement with deities in which, for example, a lantern would be offered if a particular prayer were answered as opposed to the modern one-sided form in which ones desires are requested. The repairs made to structures and the objects offered as a result of these agreements could still be seen as of 2005.