Under the name Heian-kyō, Kyōto became the second permanent capital of Japan in 794 under Emperor Kammu (781-806) after the abandonment of Heijō-kyō (Nara, 784) and a failed attempt at nearby Nagaoka-kyō (Nagaokakyō).
After the Dōkyō Incident, the influence of Buddhist monasteries was to be pushed back by banning them from the inner city area of about 4500 × 5200 meters in the new capital.
The Heian period, in which political power essentially emanated from Kyōto (though soon no longer from the emperor himself), lasted until 1185. Then, during the Muromachi period from 1333 to 1568, the Shōgunate, initially formed on the east coast, once again resided in Kyōto, but steadily lost power. With the devastation of the Ōnin War (1467-1477), the city began to decline, eventually consisting of only two separate areas on the eastern half of the city. It was not until the reign of Hideyoshi that reconstruction began in 1580. Only now temples were built within the city, which had been forbidden in the times before. In 1568, a first Christian place of worship was built, which was popularly called Namban-ji.
In the Edo period, beginning in 1603, the political center of Japan finally shifted away from Kyōto to the east coast. Courtly culture continued to be cultivated at the seat of the Tennō.
From the shogunate administration for the city of Kyōto and shogunate or imperial estates in the surrounding countryside, the (in the early years: city) Kyōto prefecture (-fu) was created in the Meiji Restoration, but it expanded to include extensive rural areas in several provinces when the prefectures were consolidated in the 1870s. In 1878/79 the prefectures were divided into counties (-gun) and urban counties/"districts" (-ku), with Kamigyō-ku and Shimogyō-ku established in the Kyōto urban area on April 10, 1879. These became the modern Kyōto County Free City (-shi) on April 1, 1889, as part of the reorganization of Japan's municipal system, and the -ku became boroughs. Until 1898, however, following an exemption of the empire's three largest cities from the city ordinance (shisei tokurei), the city of Kyōto remained without an independent administration and was governed directly by Kyōto's governor. Only then were independent mayors appointed. On April 1, 1929, the new districts of Higashiyama-ku, Nakagyō-ku, and Sakyō-ku were separated from both. On April 1, 1931, a number of surrounding towns were incorporated, creating Fushimi-ku and Ukyō-ku.
In World War II, Kyoto was originally high on the list of targets for the first use of the atomic bomb. In particular, General Leslie R. Groves called for Kyoto to be dropped because its location in a valley would have increased the impact of the blast. However, at the insistence of U.S. Secretary of War Henry L. Stimson, who had once visited the city and knew of its cultural significance, it was removed from the list. For the same reason, Kyoto was spared heavy air raids.
On September 1, 1951, Kita-ku was separated from Kamigyō-ku and Minami-ku from Shimogyō-ku. The last change in city division took place on October 1, 1976, when Nishikyō-ku was separated from Ukyō-ku and Yamashina-ku was separated from Higashiyama-ku.