Kukai left Japan for Tang China in 804, part of an official embassy that also carried the monk Saicho, founder of the rival Tendai school. In the imperial capital Chang'an, Kukai sought out the monk Huiguo, a master of the esoteric teachings then reaching China from India by way of Central Asia, and Huiguo initiated him into the tradition just months before his own death, reportedly telling Kukai to return home and spread what he had learned rather than let the lineage end in China. Kukai came back to Japan in 806 carrying texts, ritual implements and mandalas that no one in the country had seen, and over the following years built a following at court and among the older Buddhist establishments in Nara.
In 816 Kukai petitioned Emperor Saga for a remote mountain south of the capital as a place to train monks away from the political and doctrinal pressures of the city temples, and the emperor granted him Mount Koya, then a rugged, thinly settled range at roughly nine hundred meters. Construction of the monastic complex began in earnest around 819, when Kukai and his followers cleared ground for what became the Danjo Garan, the founding precinct whose great stupa, the Konpon Daito, still stands at the center of the mountain's ritual life. Kukai named the school he built there Shingon, meaning True Word, after the mantras at the center of its practice, and Koyasan has functioned as its headquarters continuously since, surviving fires, wars and periods of decline to remain the administrative and spiritual center of a tradition that now counts millions of adherents.