Magical practices in prehistory
Appearing from aboriginal tribes in Australia and New Zealand to rainforest tribes in South America, bush tribes in Africa and pagan tribal groups in Western Europe and Britain (as personified by Merlin, based on Welsh prophet Myrddin Wyllt), some form of shamanism and belief in a spirit world seems to be common in the early development of human communities. According to Joseph Campbell, the ancient cave paintings in Lascaux may have been associated with "the magic of the hunt." Much of the Babylonian and Egyptian pictorial writing characters appear derived from the same sources.
Although indigenous magical traditions persist to this day, very early on some communities transitioned from nomadic to agricultural civilizations, and with this shift, the development of spiritual life mirrored that of civic life. Just as tribal elders were consolidated and transformed into monarchs and bureaucrats, so too did shamans and adepts evolve into priestly caste.
This shift is not in nomenclature alone. It is at this stage of development that highly codified and elaborate rituals, setting the stage for formal religions, began to emerge, such as the funeral rites of the Egyptians and the sacrifice rituals of the Babylonians, Persians, Aztecs, and Maya civilizations.
Anthropological and psychological perspectives
It is a postulate of modern anthropology, at least since early 1930s, that there is complete continuity between magic and religion. In the past, there have been many attempts by anthropologists to establish some fundamental distinction between magic and religion, most notably by James George Frazer and Bronisław Malinowski; they tried to demonstrate that "magical thinking" is a form of proto-science or pseudoscience rather than a form of religious practice, and that by this line of thought, early magical beliefs developed through a post-hoc fallacy — a supplication was made on the altar, and then it rained shortly afterward. Regardless of whether the supplication was the actual cause, it was credited with the change, and thus magical beliefs could grow.
One magician's response to this is that magic is unconcerned with establishing causality, only repeatability: Ramsey Dukes explains in his book S.S.O.T.B.M.E. that questions such as "Are you sure it was your magic that cured her?" are irrelevant to the magician. "If it was a coincidence, it doesn't matter just so long as he can bring about such coincidences"
Religious practices and Magic
Closely related to magic are most forms of religious supplication, asking the divine for aid. Perhaps the most famous form is prayer, which is ordained by many religions as a spiritual duty, even aside from any effects on the outside world.
Both magic and religion contain rituals. Typically, there is a recognition that rituals do not always work; rather, it is thought to simply increase the likelihood of the desired result coming to pass. While many rituals focus on personal communion with the divine and spiritual purification, others often seek "magical" results, such as healing or good luck in battle.
Likewise, both can be divided by the effects they produce into perception and material changes. That is, whether prayer or some type of spell is used, it can either bring about an actual change (material) or a change in the way the subject feels (perception). The same prayer, for it to be "cooler" could therefore either actually raise the temperature, or simply alter the praying subject and any other targets feeling of the temperature. This is not to say that perception changes are not "real" as it could be used in healing to numb the sensation of pain, allowing healing to take place more easily
A grimoire is a textbook of magic. Such books typically include instructions on how to create magical objects like talismans and amulets, how to perform magical spells, charms and divination and also how to summon or invoke supernatural entities such as angels, spirits, and demons. In many cases the books themselves are also believed to be imbued with magical powers, though in many cultures other sacred texts that are not grimoires, such as the Bible and Qur'an, have also been believed to intrinsically have magical properties; in this manner while all books on magic could be thought of as grimoires, not all magical books could.
While the term grimoire is originally European, and many Europeans throughout history, particularly ceremonial magicians and cunning folk, have made use of grimoires, the historian Owen Davies noted that similar such books can be found all across the world, ranging from Jamaica to Sumatra, and he also noted that the first such grimoires could be found not in Europe but in the Ancient Near East.
It is most commonly believed that the term grimoire originated from the Old French word grammaire, which had initially been used to refer to all books written in Latin. By the 18th century, the term had gained its now common usage in France, and had begun to be used to refer purely to books of magic, which Owen Davies presumed was because "many of them continued to circulate in Latin manuscripts." However, the term grimoire also later developed into a figure of speech amongst the French indicating something that was hard or even impossible to understand. It was only in the 19th century, with the increasing interest in occultism amongst the British following the publication of Francis Barrett's The Magus (1801), that the term entered the English language in reference to books of magic.