Gagaku (雅楽 gagaku?, ancient imperial court music and dances, lit. "elegant music") is a type of Japanese classical music that has been performed at the Imperial Court in Kyoto for several centuries. This kind of music was first imported into Japan from China, however artistically it differs from the music of the corresponding Chinese form yayue which is a term reserved for ceremonial music. Gagaku consists of three primary repertoires:
Gagaku, like shōmyō, employs the yo scale, a pentatonic scale with ascending intervals of two, three, two, two, and three semitones between the five scale tones.
Gagaku, the oldest classical music in Japan, was introduced into Japan with Buddhism from China. In 589, Japanese official diplomatic delegations were sent to China (during the Sui dynasty) to learn Chinese culture, including Chinese court music, Gagaku. By the 7th century, the koto (a zither) and the biwa (a short-necked lute) had been introduced into Japan from China. Various instruments, including these two, were the earliest used to play gagaku.
Even though the Japanese use the same term 雅楽 (yǎyuè in Mandarin Chinese, ngahngohk in Cantonese), the form of music imported from China was primarily banquet music engaku rather than the ceremonial music of the Chinese yǎyuè. The importation of music peaked during the Tang Dynasty, and these pieces are called Tōgaku (Tang music). Gagaku pieces earlier than Tang Dynasty are called kogaku (ancient music), while those from after the Tang Dynasty are called shingaku (new music). The term gagaku itself was first recorded in 701, when the first imperial academy of music Gagakuryō was established.