This article sums up the pedigree and spell system of the Yuebei magic (月孛法, Lunar Apogee Magic) in the Song, Yuan and Ming dynasties by examining the records of the Yuebei magic in the Fahai Yizhu (法海遺珠, Forgotten Gems from the Sea of Rituals), Daofa Huiyuan (道法會元, Unified Origins of the Dao and Its Rituals) and Cangwai Daoshu (藏外道書, Daoist Texts Outside the Canon). It also outlines the practice and spread of the Yuebei magic in the society as recorded in the Ming dynasty notes and novels. By comparing the Daoist canon and other texts, we can gain an understanding of the Yuebei magic in different texts and the possible relationship between the Daoist canon and popular literature. We can also see how Daoist magic spread among and was practiced by the general public and uncover the diversity of texts. Based on the texts currently available within the Daoist canon, the Yuebei magic consists of two main types, the Taiyi Huofu magic and the Yuanhuang Yuebei magic. The former is governed by Li Yuanjun and the twelve thunder gods, and practiced when praying for rain or summoning deities or demons. Material on the Huofu magic in the Daofa Huiyuan is likely influenced by the Qingwei School (清微派, Pure Tenuity Branch). The latter is governed by Zhu Yuanjun and the ten yin-yang thunder envoys, and practiced for medical purposes or praying for rain. Even though the content is relatively straight-forward, this type of magic, with the needle magic (針法) and the scissor magic (剪法) as its main focuses, can be reconstructed from the main points illustrated by the "Postface to the Yuebei Magic" in the Cangwai Daoshu. This magic combines Daoist medical ritual and actual medical practice and has characteristics warranting further exploration. There is also considerable number of records on the Yuebei magic in Ming dynasty notes and novels, which illustrates the actual practice of the magic in the society. Besides praying for rain, the magic is also used for praying for longevity and marriages. Its rituals involve nudity and is related with the female gender, this is likely due to the counter-cultural, unkempt, nude and barefoot image of the star lord of Yuebei. The star lord of Yuebei was often considered to be a goddess in the Ming dynasty, and therefore shown as a female image. From these pieces of evidence, we can speculate that a branch of the Yuebei magic practitioners morphed the image to be female, consequently, the related rituals concerned women. This is likely a result of change in social custom and thus not recorded by the Daoist canon. The compilation of the Daoist canon went through a process of selection and elimination, a comparison between the Daoist texts and other texts can help us reflect on and use these texts in different realms, especially relevant records in notes and novels, to understand how the general public accepted, imagined Daoist magic. We can glimpse in how Daoist magic was actually practiced by the general public, by comparing and contrasting the Daoist texts and popular literature, to reveal the multiple layers of meaning contained therein