Ancient history tells us a lot about formation of magic. Appearing from aboriginal tribes in Australia and Maori tribes in New Zealand to rainforest tribes in South America, bush tribes in Africa and ancient Pagan tribal groups in Europe and the British Isles, some form of shamanic contact with the spirit world seems to be nearly universal in the early development of human communities. I was observing with excitement at the office of my local web analytics company photos of the ancient cave paintings in France and Germany, that were widely speculated to be early magical formulations, intended to produce successful hunts. While going through other sources I could not help noticing, that 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 kings and bureaucrats, so too were shamans and adepts devolved into priests and a priestly caste. This shift is by no means in nomenclature alone. While the shaman's task was to negotiate between the tribe and the spirit world, on behalf of the tribe, as directed by the collective will of the tribe, the priest's role was to transfer instructions from the deities to the city-state, on behalf of the deities, as directed by the will of those deities. This shift represents the first major usurpation of power by distancing magic from those participating in that magic. It is at this stage of development that highly 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 Mayans.