The book Ancient Jewish Magic by Bohak is the cornerstone of study into Jewish magic. The author won a scholarship from the Rothschild Foundation.
Jews have always been engaged either in the learning, practice or demonstration of magic. Writes Bohak:
Given the repeated, and well-known, biblical prohibitions against dabbling in magic, sorcery, witchcraft, augury, and all related arts, one might expect magic to be practiced, if at all, only by Jewish deviants and heretics.7 And yet, as the present study will amply demonstrate, magic was widely practiced by Jews at least from late antiquity onwards, and was in no way limited to apostate Jews, or to some religiously lax strata of Jewish society. How, then, are we to explain the enormous gap between the letter of the law and the spirit of the people?
Magic Can be Studied
Some Islamic schools and Jewish Rabbis permit the study of magic. At times even magic seems to be permitted to thwart black magic, but the opinions on these go backwards and forwards.
The Islamic view comes from the article, though not all Muslims may share this view: What is Magic and how does Islam view it?
"One who learns magic, less or more, has become an infidel and his association with Allah (s.w.t.) s completely severed.”6 However, as we have mentioned, if it is for the purpose of nullifying the sorcery of the sorcerers, then there is no harm in it. Rather, at times, on the basis of general obligation (wajib kifa’i) some individuals must necessarily learn it so that they can nullify the sorcery of a false claimant (to prophethood), should he desire to mislead the people by means of sorcery, and thus lay bare his lies and false claims.
Magic is permitted to be studied by Rabbinical injunctions:
In the sphere of magic, too, we shall see some such ingenuity – as when we discuss (in Chapter 6) the rabbinic injunction that one may not practice magic, but one may study it, and even teach it to others (including, of course, some hands-on demonstrations!... Here, however, we are sliding down a very slippery slope, for one of the greatest difficulties in the study of ancient Jewish society is to know which Jews – and especially how many Jews – observed which types of halakha, and which Jews ignored it altogether.
Finally, we may note that knowledge of magic could always prove useful in other cases too, for ancient Jewish magic, like the magic of many other cultures, provided many rituals for the detection of thieves, the exposure of liars, and the discovery of hidden guilt and buried treasures. ... Magic, then, was nominally forbidden to anyone who followed rabbinic halakha, but the study of magic was not. In some cases it was accepted, in others it was even encouraged; and here we may note that it was not only as judges that the rabbis had to have some working knowledge of magic, but as legislators and leaders as well.
Magic for Healing
The Jewish Rabbis permitted the use of magic for medicinal purposes.
Writes Bohak: p>
This rabbinic openness to medical magic can be seen in numerous instances, including the dozens of medico-magical recipes found in rabbinic literature, to which we shall return below.37 For the time being, we need only note that the acceptance of beneficial medical magic by the rabbis is probably the widest door they left open for the entry of magical recipes and practices into the very heart of rabbinic Judaism. For while the rabbis do not say this explicitly, the permission to use magic in order to save lives could implicitly legitimize apotropaic (“white”) magic of all types, including, for example, spells to save one from robbers, rituals for quelling a storm at sea, and recipes for keeping evil beasts or the evil eye away from one’s town or home, all of which are abundantly represented in the “insider” sources for late-antique Jewish magic, and some of which may be found even in rabbinic literature itself.
The use of magic against magic and magicians
The Rabbis permitted in some instances the use of magic to thwart the plans of evil sorcerers, witches and black magicians. Islam also allows this.
From the Islamic article: What is Magic and how does Islam view it?
And testifying to this is a tradition of Imam as-Sadiq (a.s.), which states that one of the magicians, who used to take money for performing his magic, approached the Imam (a.s.) and said: Sorcery had been my profession; I would take money for it and in this manner managed to meet the expenses of my life. I even performed the Hajj by means of this income, however now I have abandoned it and have repented. Is there a way for me to achieve deliverance? The Imam (a.s.) replied: Open the knots of magic but do not tie the knots of sorcery.7 From this tradition it can be inferred that it is permissible to learn and practice magic if it is for the purpose of nullifying the (evil) effects of magic.8
Islam allows the use of magic to thwart evil black magic. Similarly the Jewish injunction states according to Bohak:
... to fight magic and magicians, one may resort to magic, so as to beat the opponents at their own game. ... As we shall see below, they also had no qualms about stories in which even a sage like Rabbi Yehoshua, in the early second century ce, resorts to magical practices in order to fight a pernicious Roman witch.
the talmudic narrators are proud of Rabbi Yehoshua’s ability to use magical techniques more powerful than those of a powerful witch, and clearly see his behavior as perfectly legitimate, even desirable. This lenient attitude towards the use of magic against magic and magicians is evident in many other instances, such as when throwing a piece of iron into the cemetery and crying “H. ada” (“One”?) is forbidden as one of “the Ways of the Amorites,” but if it is done “because of keshaphim,” it is permitted, or when a Babylonian rabbi quotes the anti-witchcraft spell he had received from a real witch.
To fight magicians, you may sometimes resort to magic.
Bohak sums up the Jewish position:
To sum up what we have seen thus far, we may note that rabbinic halakha, like its biblical predecessor, prohibits its Jewish followers from practicing magic. This prohibition, however, is mitigated by several important exceptions: optical illusions are acceptable, as is the occasional creation of new life by means of “the laws of Creation.” The study of magic is permitted, and sometimes even encouraged, and the use of magic for medical purposes also is entirely acceptable. Finally, although the rabbis never say so explicitly, it is repeatedly implied that using magic in order to defeat magicians and witches is acceptable, and perhaps even desirable, and that even the use of magic against non-magicians who pose a threat to rabbinic authority is quite conceivable. Thus, not only the study of magic is endorsed by the rabbis, but even its occasional use.
It must be stressed that both Islam and Judaism forbid magic based on illusions. These are the typical party magic tricks which are nothing but optical illusions. This article proves yet again some similar Islam and Judaism really are.