"And they also did so with their secret arts." Abaye said: The laws of sorcery are like the laws of the Sabbath. Some of them are punishable by stoning, some are exempt but forbidden, and some are permitted at the outset. One who performs a real act is liable to stoning. One who merely deceives the eyes is exempt but it is forbidden. (Rabbi Yochanan says:) Permitted at the outset, as in the case of Rav Chanina and Rav Hoshaya, who every Sabbath eve would engage in the laws of Creation and would create for themselves a third-grown calf and eat it. Rabbi Chiyya bar Abba said: "with their incantations" (belateihem) refers to the work of demons; "with their flames" (belahateihem) refers to the work of sorcery, and likewise it says, "and the flame of the sword" (Genesis 3:24). Rabbi Yochanan said: Why is their name called keshafim [sorcery]? Because they contradict the heavenly retinue. Abaye said: One who is particular about the vessel works through a demon; one who is not particular about the vessel works through sorcery. Yochani and Mamre said to Moses: You are bringing straw to a town full of straw! He said to them: People say, To a town of vegetables, bring vegetables.
The Law of Sorcery and the Magicians Who Defied Heaven
Yalkut Shimoni on Torah 182:1
וַיַּעֲשׂוּ גַם הֵם וְגוֹ' בְּלַהֲטֵיהֶם. אָמַר אַבַּיֵּי, הִלְכוֹת כְּשָׁפִים כְּהִלְכוֹת שַׁבָּת, יֵשׁ מֵהֶם בִּסְקִילָה, וְיֵשׁ מֵהֶם פָּטוּר אֲבָל אָסוּר, וְיֵשׁ מֵהֶם מֻתָּר לְכַתְּחִלָּה, הָעוֹשֶׂה מַעֲשֶׂה, בִּסְקִילָה, הָאוֹחֵז אֶת הָעֵינַיִם, פָּטוּר אֲבָל אָסוּר, (רַבִּי יוֹחָנָן אוֹמֵר) מֻתָּר לְכַתְּחִלָּה כִּדְרַב חֲנִינָא וְרַב הוֹשַׁעְיָא, כָּל מַעֲלֵי שַׁבְּתָא הָווּ עָסְקֵי בְּהִלְכוֹת יְצִירָה וּמִבְרִי לְהוּ עֶגְלָא תִּלְתָא וְאָכְלֵי לֵיהּ. אָמַר רַבִּי חִיָּיא בַּר אַבָּא, "בְּלָטֵיהֶם" אֵלּוּ מַעֲשֵׂה שֵׁדִים, 'בְּלַהֲטֵיהֶם' אֵלּוּ מַעֲשֵׂה כְּשָׁפִים, וְכֵן הוּא אוֹמֵר (בראשית ג, כד) "וְאֵת לַהַט הַחֶרֶב". אָמַר רַבִּי יוֹחָנָן, לָמָּה נִקְרָא שְׁמָם כְּשָׁפִים, שֶׁמַּכְחִישִׁין פָּמַלְיָא שֶׁל מַעְלָה. אָמַר אַבַּיֵּי, דְּקָפִיד אֲמָנָא, שֵׁד, דְּלָא קָפִיד אֲמָנָא, כְּשָׁפִים. אָמְרֵי לֵיהּ יוֹחֲנִי וּמַמְרֵא לְמֹשֶׁה, תֶּבֶן אַתָּה מַכְנִיס לְעֳפָרַים. אָמַר לְהוּ, אָמְרֵי אִינְשֵׁי, לְמָתָא דְּיַרְקָא יַרְקָא שְׁקִיל.