Cloistered Emperor
At the end of the Heian period (the latter half of the 12th century), the Heike clan, which originated from the Imperial guard of Cloistered Emperor, who were highly respected during the cloistered rule, rose to prominence, and the Minamoto clan, which had defeated the Heike clan, led to the rise of the samurai society. In 1192, the Kamakura shogunate, a samurai government, was officially established. From the time of the Genpei War, the existence of onmyōji was essential for both clans to establish their code of conduct. For this reason, the Kamakura shogunate also tended to emphasize onmyōdō. From the time when Minamoto no Yoritomo, the founder of the shogunate, went to war to seize power, he chose auspicious days predicted by onmyōji when deciding on actions to be taken in the early years of the shogunate. The 2nd shogun, Minamoto no Yoriie, followed his father's example by inviting an onmyōji from the capital. However, his personal life was not influenced by an onmyōji, and he used them only to supplement the formality of official events.