By the turn of the millennium, apocalyptic and messianic movements began to emerge in widespread areas of China. For example, in the year 3 B.C.E., many inhabitants of Shandong left home and headed to the west in search of the goddess Xiwangmu, the Queen Mother of the West, as they believed she would save them from an unpopular ruler. In 184 C.E., the Yellow Turban rebels in eastern China tried unsuccessfully to overthrow their ruler. They based their actions on a sacred text called the Taiping jing, or Scripture of Great Peace, which described a utopian realm governed by a benevolent sage-king.
In 142 C.E., a transformative group appeared that shared some characteristics with these movements. Called the Way of the Celestial Masters, it was founded by a fangshi named Zhang Taoling. Zhang said he had been visited by a deified Laozi, who gave to him a new law and a new mandate. He was to rid the world of decadence and establish a new, perfect realm, populated by the "seed people," the members of this new religion. Rather than overthrow the Han ruler by force, Zhang was to create an interim kingdom that would prepare the way for a new dynasty. Zhang was known as the Celestial Master, or the representative of Laozi on earth, and this position was passed on after his death through a line of male heirs.
The movement spread rapidly, and for a time, established an independent theocracy in Sichuan. It had elaborate organizational structures, modeled after Han dynasty governmental organization, and the titles of religious leaders were also taken from the titles of Han officials. The state was divided into twenty-four regions, each administered by twenty-four officials, each of whom commanded thousands of spirits. Families were assigned to districts, and registers were kept with accounts of marriages, births, deaths, and other changes in the civic status of each member.
The movement opposed animal sacrifices, stating that the gods do not eat or drink; rather, they consume only qi, the cosmic breath which is the source of all life. It was also against popular religion, exposing magicians and messiahs who took advantage of people, and battled religious extremism. Any competing group was defined as a "wrong path"; another name for the movement was Zhengyi, or "Correct One."
The Way of the Celestial Masters synthesized many of the elements of immortality cults, and of literati Taoism; unlike the latter, however, its membership was not limited to members of the upper classes. It was open to women and ethnic minorities as well, and they were even accepted as religious leaders.
By the 3rd century C.E. it had become a prosperous movement with many followers, including powerful families and members of the aristocracy. As a result of an alliance with the new Wei dynasty (220-265 C.E.), a large number of followers relocated farther to the north, and many of its leaders were awarded titles by the Wei government. For a time, the Wei rulers turned to the Celestial Masters to validate their rule. As the fortunes of the short-lived dynasty fell, so too did the fortunes of the movement.
This was the first of several enduring Taoist religious organizations to emerge in China. In the 4th century, an individual named Yang Xi purportedly began to receive visits from a number of different gods and spirits, including legendary immortals and local saints. Over a period of six years they dictated a large number of texts to him. The authenticity of these revelations was attested to by their literary quality and the elegant calligraphy in which they were written. These texts were known as Shangqing, or Highest Purity. They contained elements of Ge Hong's alchemical speculations, considerable borrowings from the Way of Celestial Masters, some elements from local traditions, and superficial aspects of Buddhism.
Originally a textual classification rather than a religious organization, Shangqing spread rapidly among the aristocracy, and claimed and won supremacy over the Way of the Celestial Masters. In the 5th and 6th centuries, particularly under the leadership of Tao Hongjing (456-536), a great theoretician, historian, and bibliographer who collected and preserved all of Yang's writings, Shangqing was shaped into an organization with monasteries and community structures.
What was unique about Shangqing practice was that herbs, elixirs, and bodily practices were replaced by an internal approach to the quest for immortality. Practitioners served as their own priests, undertaking meditative and visionary journeys that led to physical transformation. New deities were introduced who served as spiritual guides, nourishing adepts with their divine qi, and taking them on mystical travels to celestial kingdoms.