With the fall of the Han dynasty, China entered a period of great political turmoil, only interrupted by a brief reunification under the Western Jin (265-317). But the latter were unable to withstand another offensive from nomadic tribes in search of fertile lands irrigated by the Yellow River. Northern China then saw a succession of sixteen ephemeral kingdoms, including the Northern Wei, who established a new capital in Pingcheng (close to present-day Datong). In the face of these repeated invasions, the Chinese dynasty retreated into the south, driven out by the Xiongnu nomads. In these southern regions, the emperors founded a new capital, today known as Nanjing (Nankin), where they maintained elegant courts and supported painters, poets and calligraphers such as the painter Gu Kaizhi (345-411) and the calligrapher Wang Xizhi (307-365), considered the father of Chinese calligraphy. The landscape painter Wang Wei (415-443), none of whose works have come down to us, unfortunately, laid the foundations of landscape painting.
In the northern regions, Buddhism, which had come from India and was probably introduced to China in the early Christian era, gained ground among the Barbarian dynasties with its egalitarian vision and comforting humanism in this troubled period. The Buddhist doctrines were passed on along the Silk Road, where travelling patriarchs and monks founded monasteries, as in Khotan, Turfan, Dunhuang, the gateway to China, and Maijishan (Gansu province). After some reluctance, the Northern Wei dynasty (386-534) made Buddhism a state religion and subsidised the construction of vast temple grottoes housing sculptures and paintings with rigorous iconography. The first group of caves designed by the Wei rulers was at Yungang, where the work began in 460. The grottoes were excavated and carved with thousands of divinities in the round and in high relief up until 494, when the capital of the Wei was moved to Luoyang. The following year, new grottoes in the form of ex-votos began to be carved near Luoyang, in Longmen. After the full, massive forms of the Yungang sculptures, inherited from Indian art, came sharp, linear forms, reflecting a spirituality at its height. Religious sculptures continued to be added to this site under the following dynasties until the 8th century.