In the Middle Ages and early modern period, the term was used to refer to those who performed prayers and divination in the private sector, and some of them were regarded as a kind of clergy.
Based on the ancient Chinese concept of yin and yang and five phases, which began in the Xia and Shang dynasties and was almost completed in the Zhou dynasty, that all phenomena are based on the combination of yin-and-yang five phases of wood, fire, earth, metal, and water, onmyōji is a uniquely Japanese profession that is responsible for astrology, calendar, I Ching, water clock, etc., which are closely related to this concept.
The yin-and-yang five phases philosophy itself, which is the premise of this system, is thought to have come directly from the mainland China (the Northern and Southern dynasties or earlier) or via the western part of the Korean Peninsula (Goguryeo and Baekje) during the Asuka period, or at the latest by the time the Five Classics doctors came to Japan from Baekje in 512 or the I Ching doctors came to Japan in 554.
In addition, the influence of yin-and-yang five phases philosophies became apparent in the establishment of Prince Shōtoku's seventeen-article constitution and the Twelve Level Cap and Rank System.
Later, Emperor Tenmu was such a master of astrology and fugue that he took his own divination tools and told fortunes during the Jinshin War.
However, since the technical officers, such as doctors and onmyōji, were in charge of technology that had been introduced from the continent, they were appointed by foreigners who were well versed in academics and skilled in reading Classical Chinese texts, especially monks who had come from the Han dynasty and the Sui dynasty in mainland China, as well as from Goguryeo and Baekje, which had power on the west coast of the Korean Peninsula, and rarely from Silla, which initially had power on the east coast of the Korean Peninsula.
Under the ritsuryō system, it was strictly forbidden for any outsider (not only priests and monks, but also all government officials and private citizens) to study astrology, yin and yang, calendars, and time management, and to preach about disasters and good omens, except for those who were appointed as trainees at the Bureau of Onmyō.
For this reason, until the beginning of the Heian period (early 9th century), when the ritsuryō system was relatively strictly enforced, onmyōdō was managed as classified information monopolized by the Bureau of Onmyō.
As a result, the two families were promoted to more senior positions beyond the official rank of the Bureau of Onmyō in the ritsuryō system, even though they were in reality only practitioners of onmyōdō.
After the assassination of Fujiwara no Tanetsugu in 785, the Emperor Kanmu was frightened by a vengeful spirit of Prince Sawara, his younger brother, due to the frequent incidents of personal disasters and mourning.
Against this backdrop, in addition to the ancient Shintoism, religious beliefs in the stars and Taoist spells, such as those using sacred symbols, came to be the focus of attention.
[citation needed] Furthermore, in the process of the Hokke of the Fujiwara clan's expansion and establishment of power in the Imperial court, political conflicts among nobles intensified, and there were many occasions when onmyōdō was used for slander and defamation aimed at the downfall of rival forces.
In addition, the fact that people outside the Bureau of Onmyō, such as Fujiwara no Morosuke and Miyoshi Kiyotsura, had mastered astrology, onmyōdō, I Ching, and calendars shows that the classified information policy under the ritsuryō system, which prohibited the leakage of onmyōdō outside the Bureau of Onmyō, had already practically failed by this time.
As a result, informal onmyōji, who were not regular government officials and belonged to the Bureau of Onmyō, began to privately associate with the nobles, divining their good and bad fortune, and secretly performing rituals to ward off evil.
The onmyōji became a charismatic spiritual ruler in the Imperial court with a strong tinge of religious spells and rituals, and came to wield a powerful influence.
From the middle of the Heian period onward, onmyōji had a great influence on the central government of the Imperial court, from political management and personnel decisions to the abdication of the Emperor.
The fourth shogun of the Kamakura shogunate, Kujō Yoritsune, received a request from the cabinet for a policy to draw an irrigation canal from the Tama River system as a public works and use it to secure drinking water and develop paddy field after the development of wetlands in Musashi Province (present-day Metropolis and Saitama Prefecture) had been completed.
The fact that onmyōji, who were feared and shunned in the court at the time because of their duties, became one of senior government positions was a groundbreaking event that caused a sensation.
[note 3] The Tsuchimikado family had gained the support of both the Imperial court and Muromachi shogunate, and up to this point, it seemed to have perfected its power as an onmyōji.
However, they rarely served in Heian-kyō and remained in Wakasa Province to perform various rituals, including the festival of the Great Emperor of the Sacred Mountain of the East.
With the complete collapse of the ritsuryō system and the suppression of Toyotomi Hideyoshi, the onmyōji as an official position in the Bureau of Onmyō lost its presence.
Around this time, from the end of the Kamakura period to the beginning of the Northern and Southern courts period (early 14th century to early 15th century), the book Sangoku Sōden In'yō Kankatsu Hoki Naiden Kin'u Gyokuto Shū [ja] written under the name of Abe no Seimei became widely known as a book of private onmyōdō, which were linked to the belief in Gozu Tennō.
They were sometimes called "doctors,"[3] but there were also those who claimed to be onmyōji and traveled around Japan on the pretext of offering mediumship and necromancy services, charging high fees for their prayers and divinations.
In addition to the patronage they received from the Imperial court, they also succeeded in getting the Tokugawa shogunate, the de facto government, to grant them the sole right to control onmyōji throughout Japan.
On 9 December 1870, a decree was issued banning the Tensha Tsuchimikado Shinto [ja] and the spread of onmyōdō to the civilian population as it was a superstition.
However, in reality, calendars derived from the onmyōdō still circulated unofficially, with Calendrical Notes [ja] gaining popularity and walking on their own.
Other than that, there are only a few vestiges of onmyōdō surviving in local onmyōji such as the Izanagi school [ja] in Kami City (formerly Monobe Village), Kōchi Prefecture.
Based on the occult image of the spell-binding onmyōji of the Heian period, various creative works and characters were created to exaggerate their superhumanity and peculiarity.
In the "Onmyōryōshiki (Japanese: 陰陽寮式, literally: Procedures of the Bureau of Onmyō)" of the book "Engishiki," there is a record of the festivals held by onmyōji in the court.
With time, practices have advanced and become more interlinked with Buddhism and Shinto traditions, and it gradually evolved to be the syncretic system adapting to the spiritual needs of various periods.