Forms of religion in China throughout history have included animism during the Xia dynasty, which evolved into the state religion of the Shang and Zhou dynasties. Alongside an ever-present undercurrent of Chinese folk religion, highly literary, systematized currents related to Taoism and Confucianism emerged during the Spring and Autumn period. Buddhism began to influence China during the Han dynasty, and Christianity and Islam appeared during the Tang.

Today, the government of the People's Republic of China is officially atheist. The United Front Work Department of the Central Committee of the Chinese Communist Party manages the official religious bodies of the five recognized religions in the country: Buddhism, Taoism, Catholicism, Protestantism, and Islam.

Proto-Chinese and pre-imperial culture

Prior to the formation of Chinese civilisation and the spread of world religions in the region known today as East Asia (which includes the territorial boundaries of modern-day China), local tribes shared animistic, shamanic and totemic worldviews. Shamans acted like mediators, communicating prayers, sacrifices, or offerings directly to the spiritual world, a heritage that survives in some modern forms of Chinese religion.

Ancient shamanism is especially connected to ancient Neolithic cultures such as the Hongshan culture. The Flemish philosopher Ulrich Libbrecht traces the origins of some features of Taoism to what Jan Jakob Maria de Groot called "Wuism", that is Chinese shamanism.

Libbrecht distinguishes two layers in the development of the Chinese theology and religion that continues to this day, traditions derived respectively from the Shang (1046 BCE) and subsequent Zhou dynasties (1046–256 BCE). The religion of the Shang was based on the worship of ancestors and god-kings, who survived as unseen divine forces after death. They were not transcendent entities, since the universe was "by itself so", not created by a force outside of it but generated by internal rhythms and cosmic powers. The royal ancestors were called , and the utmost progenitor was . Shangdi is identified with the dragon, symbol of the unlimited power (qi), of the "protean" primordial power which embodies yin and yang in unity, associated to the constellation Draco which winds around the north ecliptic pole, and slithers between the Little and Big Dippers. Already in Shang theology, the multiplicity of gods of nature and ancestors were viewed as parts of Di, and the four and their as his cosmic will.

The Zhou dynasty, which overthrew the Shang, was more rooted in an agricultural world view, and they emphasised a more universal idea of Tian. The Shang dynasty's identification of Shangdi as their ancestor-god had asserted their claim to power by divine right; the Zhou transformed this claim into a legitimacy based on moral power, the Mandate of Heaven. In Zhou theology, Tian had no singular earthly progeny, but bestowed divine favour on virtuous rulers. Zhou kings declared that their victory over the Shang was because they were virtuous and loved their people, while the Shang were tyrants and thus were deprived of power by Tian.

John C. Didier and David Pankenier relate the shapes of both the ancient Chinese characters for Di and Tian to the patterns of stars in the northern skies, either drawn, in Didier's theory by connecting the constellations bracketing the north celestial pole as a square, or in Pankenier's theory by connecting some of the stars which form the constellations of the Big Dipper, more broadly Ursa Major and Ursa Minor. Cultures in other parts of the world have also conceived these stars or constellations as symbols of the origin of things, the supreme godhead, divinity and royal power.

Latter Zhou and Warring States

By the 6th century BCE the power of Tian and the symbols that represented it on earth (architecture of cities, temples, altars and ritual cauldrons, and the Zhou ritual system) became "diffuse" and claimed by different potentates in the Zhou states to legitimise economic, political, and military ambitions. Divine right no longer was an exclusive privilege of the Zhou royal house, but might be bought by anyone able to afford the elaborate ceremonies and the old and new rites required to access the authority of Tian.

Besides the waning Zhou ritual system, what may be defined as 'wild' () traditions, or traditions "outside of the official system", developed as attempts to access the will of Tian. The population had lost faith in the official tradition, which was no longer perceived as an effective way to communicate with Heaven. The traditions of the "Nine Fields" () and of the Yijing flourished. Chinese thinkers, faced with this challenge to legitimacy, diverged in a "Hundred Schools of Thought", each proposing its own theories for the reconstruction of the Zhou moral order.

Background of Confucianism

Confucius (551–479 BCE) appeared in this period of political decadence and spiritual questioning. He was educated in Shang-Zhou theology, which he contributed to transmit and reformulate giving centrality to self-cultivation and human agency, and the educational power of the self-established individual in assisting others to establish themselves (the principle of 'loving others'. As the Zhou reign collapsed, traditional values were abandoned resulting in a period of moral decline. Confucius saw an opportunity to reinforce values of compassion and tradition into society. Disillusioned with the widespread vulgarisation of the rituals to access Tian, he began to preach an ethical interpretation of traditional Zhou religion. In his view, the power of Tian is immanent, and responds positively to the sincere heart driven by humaneness and rightness, decency and altruism. Confucius conceived these qualities as the foundation needed to restore socio-political harmony. Like many contemporaries, Confucius saw ritual practices as efficacious ways to access Tian, but he thought that the crucial knot was the state of meditation that participants enter prior to engage in the ritual acts. Confucius amended and re-codified the classical books inherited from the Xia, Shang, and Zhou dynasties, and composed the Spring and Autumn Annals.

Philosophers in the Warring States compiled in the Analects, and formulated the classical metaphysics which became the lash of Confucianism. In accordance with the Master, they identified mental tranquillity as the state of Tian, or the One (), which in each individual is the Heaven-bestowed divine power to rule one's own life and the world. Going beyond the Master, they theorised the oneness of production and reabsorption into the cosmic source, and the possibility to understand and therefore reattain it through meditation. This line of thought would have influenced all Chinese individual and collective-political mystical theories and practices thereafter.

According to Zhou Youguang, the word for Confucius's occupation (), originally referred to shamanic methods of holding rites and existed before Confucius' times, but with Confucius it came to mean devotion to propagating such teachings to bring civilisation to the people. Confucianism was initiated by Confucius, developed by Mencius (-289 BCE) and inherited by later generations, undergoing constant transformations and restructuring since its establishment, but preserving the principles of humaneness and righteousness at its core.

Qin and Han dynasties

The Qin (221–206 BCE), and especially Han dynasty (206 BCE–220 CE), inherited the philosophical developments of the Warring States period moulding them into a universalistic philosophy, cosmology and religion. It was in this period that religious focus shifted to the Earth, regarded as representative of Heaven's power. In the Han period, the philosophical concern was especially the crucial role of the human being on earth, completing the cosmological trinity of Heaven-Earth-humanity (). Han philosophers conceived the immanent virtue of Tian as working through earth and humanity to complete the 'space-time'.

The short-lived Qin dynasty started by Qin Shi Huang (r. 247–220 BCE), who reunified the Warring States and was the first Chinese ruler to use the title of "emperor", chose Legalism as the state ideology, banning and persecuting all other schools of thought. Confucianism was harshly suppressed, with the burning of Confucian classics and killing of scholars who espoused the Confucian cause. The state ritual of the Qin was indeed similar to that of the following Han dynasty. Qin Shihuang personally held sacrifices to Di at Mount Tai, a site dedicated to the worship of the supreme God since pre-Xia times, and in the suburbs of the capital Xianyang. The emperors of Qin also concentrated the cults of the five forms of God, previously held at different locations, in unified temple complexes.

The universal religion of the Han, which became connected at an early time with the proto-Taoist Huang–Lao movement, was focused on the idea of the incarnation of God as the Yellow Emperor, the central one of the Wufang Shangdi. The idea of the incarnation of God was not new, as already the Shang royal lineage regarded themselves as divine. Their progenitors were "sons of God", born by women who "stepped on the imprinting" of Di. This was also true for royal ancestors of the early Zhou dynasty. The difference rests upon the fact that the Yellow Emperor was no longer an exclusive ancestor of some royal lineage, but rather a more universal archetype of the human being. The competing factions of the Confucians and the fangshi, regarded as representatives of the ancient religious tradition inherited from previous dynasties, concurred in the formulation of Han state religion, the former pushing for a centralisation of religio-political power around the worship of the God of Heaven by the emperor, while the latter emphasising the multiplicity of the local gods and the theology of the Yellow Emperor. Besides these developments of common Chinese and Confucian state religion, the latter Han dynasty was characterised by new religious phenomena: the emergence of Taoism outside state orthodoxy, the rise of indigenous millenarian religious movements, and the introduction of the foreign religion of Buddhism.

Yellow Emperor cult

By the Han dynasty, the universal god of early Shang–Zhou theology had found a new expression with the use of the names of Taiyi, "Supreme Oneness of the Central Yellow" (), or the "Yellow God of the Northern Dipper" (i.e. Ursa Major), other than by names inherited from the previous tradition. Although the name Taiyi became prominent in the Han, it harkens back to the Warring States, as attested in the poem The Supreme Oneness Gives Birth to Water, and possibly to the Shang dynasty as Dayi (), an alternative name for Shang's (and universe's) greatest ancestor. Han theology focalised on the Yellow Emperor, a culture hero and creator of civility, who, according to a definition in apocryphal texts related to the Yellow River Map, "proceeds from the essence of the Yellow God of the Northern Dipper", is born to "a daughter of a chthonic deity", and as such he is "a cosmic product of the conflation of Heaven and Earth".

In the myth, the Yellow Emperor was conceived by a virgin mother, Fubao, who was impregnated by Taiyi's radiance (yuanqi, "primordial pneuma") from the Big Dipper after she gazed at it. Through his human side, he had , another reference to the Ursa Major. Didier has studied the parallels that the Yellow Emperor's mythology has in other cultures, deducing a plausible ancient origin of the myth in Siberia or in north Asia.