Emperor Kanmu moved the Japanese capital to a new site in 794 CE, naming it Heian-kyo, "capital of peace and tranquility," after an earlier attempt to relocate the court to nearby Nagaoka-kyo had gone badly. Part of the motive was distance: the previous capital, Nara, had grown politically entangled with its own great Buddhist temples, and Kanmu wanted an administration less encumbered by monastic influence. The new city was laid out on a rectangular grid modeled on the Tang dynasty Chinese capital of Chang'an, with the imperial palace at its northern center and broad avenues running south, a plan whose street pattern is still traceable in the modern city.
Heian-kyo, gradually known simply as Kyoto, "capital city," remained Japan's seat of imperial and religious authority for more than a thousand years even as real political power shifted to shogunal governments based elsewhere. The emperor, understood in Shinto terms as descended from the sun goddess Amaterasu, continued to perform the court's ceremonial and religious functions from the city through repeated changes of military rule, until the Meiji Restoration moved the imperial seat to Tokyo in 1868, ending Kyoto's thousand year run as the country's capital.