In 685, as the principles of inyo gogyo grew more popular, with the term 'onmyoji' starting to be used, it was put into statutory form to install Onmyoryo as a ryo (in line with the ritsuryo system) as a division of Department of Nakatsukasasho, by the ritsuryo formally announced in the Yoro period in 718 and when it was stipulated that tenmon hakase, onmyo hakase, onmyoji, reki hakase, and rokoku hakase be made permanent posts as gikan (bureaucrats with specialized skills), they began to officially perform divinations alongside jingikan (a bureaucrat in charge of Shinto ceremonies) who were responsible for kiiboku (fortune telling using turtle shells).
685年（天武天皇13年）には「陰陽師」という用語が使い始められるなど、陰陽五行思想はさらに盛んとなり、718年の養老律令において、中務省の内局である寮(律令制)としての陰陽寮の設置が明文化され、これに技官として天文博士・陰陽博士・陰陽師・暦博士・漏刻博士が常任されることが規定されると、神祇官の龜卜と並んで公的に式占を司ることとなった。