The largest and oldest Temple of Confucius is found in Confucius's hometown, present-day Qufu in Shandong Province. It was established in 479 BC, one year after Confucius's death, at the order of the Duke Ai of the State of Lu, who commanded that the Confucian residence should be used to worship and offer sacrifice to Confucius. The temple was expanded repeatedly over a period of more than 2,000 years until it became the huge complex currently standing.
The development of state temples devoted to the cult of Confucius was an outcome of his gradual canonisation. In 195 BC, Han Gao Zu, founder of the Han Dynasty (r. 206195 BC), offered a sacrifice to the spirit of Confucius at his tomb in Qufu. Sacrifices to the spirit of Confucius and that of Yan Hui, his most prominent disciple, began in the Imperial University (Biyong) as early as 241.
In 454, the first state Confucian temple was built by the Liu Song dynasty of south China (420 to 479). In 489, the Northern Wei constructed a Confucian temple in the capital, the first outside of Qufu in the north. In 630, the Tang Dynasty decreed that schools in all provinces and counties should have a Confucian temple, as a result of which temples spread throughout China. Well-known Confucian shrines include the Confucian Temple in Jianshui, the Confucian Temple in Xi'an (now the Forest of Steles), the Fuzi Miao in Nanjing, and the Confucian Temple in Beijing, first built in 1302.