Nanzen-ji was founded in the 13th century by the emperor Kameyama, who had originally built an imperial villa on what were to become the temple grounds. By the 14th century the temple had become the most powerful Zen temple in Japan. Today, it is the principal temple of the Rinzai Zen sect, and it remains one of the most important Zen Buddhist temples in Japan. Destroyed by fire on multiple occasions during the 14th and 15th centuries, it was rebuilt in 1597, though most of the current architecture dates from the 17th century and later.