Tianshi dao 天師道, the Way of the Celestial Masters, was an early school of religious Daoism and the first tradition that was accepted by the state as a true religion. It originated in the movement of the Five-Pecks-of-Grain School (wudoumi dao 五斗米道), whose leaders of the Zhang 張 lineage had created an independent theocratic state in the region of Hanzhong 漢中 in the borderland of today's Sichuan, Shaanxi and Hubei. It flourished during the late Eastern Han period 東漢 (25-220 CE).
In 215 CE, the powerful warlord of the north, Cao Cao 曹操, conquered the region of Hanzhong, and Zhang Lu 張魯 (d. 216) capitulated. His theocracy had ended, but the religious activities continued to prosper in this region.
As to Zhang Lu himself, legend holds that he was enfeoffed by Cao Cao as Marquis of Langzhong 閬中 and that a son of his was married to a daughter of Cao Cao. Together with Zhang Lu, thousands of households were resettled from the Hanzhong region to the old capitals in the north, Chang'an and Luoyang. This was necessary because these heartlands of the Chinese empire had bled off their population during the long-lasting wars at the end of the Han period.
At the end of the third century, therefore, Chen Zhuan 陳瑞 revived the teaching of the Five-Pecks-of-Grain School and preached among the population. He concentrated on the treatment of dead and the exorcism of ghosts. Chan also called himself Celestial Master (tianshi 天師) and wore crimson clothes and a special cap. The government therefore suspected him of rebellion, captured and executed him and burnt down the ceremonial halls as that of a "heretic sect" not following the proper custom of a filial treatment of the death.
The practices of Chen Zhuan's school were prohibited but continued flourishing among the population. A decade later the government of the Jin dynasty 晉 (265-420) fell apart, and popular uprisings in Sichuan again made this province independent. Fan Changsheng 范長生 (d. 318), a Daoist leader, conquered Chengdu. He became Counsellor-in-chief (chengxiang 丞相) of Li Xiong 李雄 (274-334), who had proclaimed his own empire of Cheng-Han 成漢 (304-347) in Shu 蜀 (Sichuan). After Fan Changsheng's death, his son Fan Ben 范賁 (d. 349) became the new Grand Master of Heaven and Earth (tiandi taishi 天地太師). In 347, Shu again became part of the Jin empire.
During the rule of the Wei 魏 (220-265) and the Jin dynasties, the religion of the Five-Pecks-of-Grain had spread in northern China, where many landowners and even imperial princes became adherents of Daoism. The school was at that time commonly called the School of the Celestial Masters. In the fourth century, political turmoils forced the court and a large part of the nobility and landowners to flee to the southwest, where they established the Eastern Jin Dynasty 東晉 (317-420). They brought their religion with them, and the Way of the Celestial Masters thus arrived in the lower Yangtze region.
The first great teacher was Du Zigong 杜子恭, whose lineage took over the tradition of the Celestial Masters for many generations.
During the Liu-Song period 劉宋 (420-479), a relative to the family Du, Sun En 孫恩 (d. 402), staged a large rebellion with a religious background. After his failure and sucide, his brother-in-law Lu Xun 盧循 (d. 411) held up the rebellion for some further time.
Although the Celestial Masters Tradition had become a nation-wide religion, it did not produce a figure of an integrating leader who was able to hold together the communities of believers. The religion of Daoism had thus not any more the potency to care for the spiritual desires of most of its adherents, which came from the lower strata of society. The Celestial Masters had one the one hand lost contact to the masses of the populace, and on the other hand did not have the chance to forge an alliance with those in power.
The tradition of the Celestial Masters therefore transformed into a common religion, and two different schools emerged, one in the north, led by Kou Qianzhi 寇謙之 (365-447), who cooperated with the government, and one in the south, created by Lu Xiujing 陸修靜 (406-477), who made Daoism a popular religion. These two schools were the Northern Way of the Celestial Masters (Bei tianshi dao 北天師道) and the Southern Way of the Celestial Masters (Nan tianshi dao 南天師道), respectively.