Beginning in 366 AD, people in China built the earliest Buddhist temples in China. These first Buddhist temples at Mogao were carved into caves in the side of cliffs, like the earlier Buddhist temples at Ajanta in India. Buddhist monks and nuns used the caves as places to get away from the world and concentrate on achieving enlightenment. This was the same way Christian monks and nuns did in caves in the Egyptian desert at just the same time.
Buddhist monks and nuns also used the caves as places to keep sacred books and art. Because the caves were right on the Silk Road, many people passed by them every day. In addition to being religious temples, these caves also served as hotels for people traveling on the Silk Road, just as the caves at Ellora served as hotels there. The monks and nuns made money by charging travelers for rooms and for food.
About 460 AD, the Wei emperors started another set of Buddhist cave temples not far away at Yungang. The Wei emperors had persecuted Buddhists at first, and now these temples were their way of saying they were sorry. The monks and nuns carved at least forty-five different temples into the cliff, each one full of paintings, carvings, and stone statues.
The carvings in the Yungang caves are mainly of the Buddha and various bodhisatvas. The style shows that artists were traveling all across Asia at this time: there are artistic influences from Iran and the Roman Empire, as well as from Buddhist India. Indeed, probably the main influences on Chinese art at this time were coming from the vibrant cultures of Central Asia, where there were a lot of rich families that built many great buildings at this time.