The Way of the Five Pecks of Rice (Chinese: 五斗米道; pinyin: Wǔ Dǒu Mǐ Dào) or the Way of the Celestial Master, commonly abbreviated to simply The Celestial Masters, was a Chinese Taoist movement founded by the first Celestial Master Zhang Daoling in 142 CE. At its height, the movement controlled a theocratic state in the Hanzhong valley, north of Sichuan. In 215 CE, the state was incorporated into Cao Cao's Kingdom of Wei, and the followers of the Celestial Master were dispersed all over China.
The Celestial Masters believed that qi pervaded everything, and in order to achieve immortality, the correct balance of qi had to be present within the body. Having a poor quantity of qi in the body, would result in illness, and eventually death. Meditation could be used to restore qi to the body, but sex was to be avoided, as it could result in the loss of qi. If there was the correct balance of qi within the body upon death, an adherent could 'feign death' and be reborn. If not, an adherent would be transported to an earthly prison where he would face eternal torment.
The Hanzhong state was divided into 24 regions which were led by an official. Each district had a civil register which recorded people's names and ranks. Three times a year, the registers were updated at the same time as an important feast. While a child's rank rose automatically, adults had to raise their own rank through religious achievement or marriage. Higher ranked people had more divine generals at their command, which could be used to fight demons that caused bad luck or disease. The state had a system of law that encouraged confession and benevolence rather than strict punishment. Criminals were asked to confess their crimes and meditate, and were given public work to do as a sentence. Few texts written by the Hanzhong Celestial Masters survive, with the most important being the Xiang'er commentary to the Dao De Jing. While the Hanzhong state lasted for only twenty-five years, their beliefs influenced all subsequent Daoist movements.