Tafsir Ibn Kathir -> Surah Al-Baqarah -> Learning Magic is Kufr

Allah said,

﴿وَمَا يُعَلِّمَانِ مِنْ أَحَدٍ حَتَّى يَقُولاَ إِنَّمَا نَحْنُ فِتْنَةٌ فَلاَ تَكْفُرْ﴾

(But neither of these two (angels) taught anyone (such things) till they had said, "We are for trial, so disbelieve not (by learning this magic from us).)

Abu Ja`far Ar-Razi said that Ar-Rabi' bin Anas said that Qays bin `Abbad said that Ibn `Abbas said, "When someone came to the angels to learn magic, they would discourage him and say to him, `We are only a test, so do not fall into disbelief.' They had knowledge of what is good and evil and what constitutes belief or disbelief, and they thus knew that magic is a form of disbelief. When the person who came to learn magic still insisted on learning it, they commanded him to go to such and such place, where if he went, Satan would meet him and teach him magic. When this man would learn magic, the light (of faith) would depart him, and he would see it shining (and flying away) in the sky. He would then proclaim, `O my sorrow! Woe unto me! What should I do.'' Al-Hasan Al-Basri said that this Ayah means, "The angels were sent with magic, so that the people whom Allah willed would be tried and tested. Allah made them promise that they would not teach anyone until first proclaiming, `We are a test for you, do not fall into disbelief.''' It was recorded by Ibn Abi Hatim. Also, Qatadah said, "Allah took their covenant to not teach anyone magic until they said, `We are a test. Therefore, do not fall in disbelief.'''

Also, As-Suddi said, "When a man would come to the two angels they would advise him, `Do not fall into disbelief. We are a test. ' When the man would ignore their advice, they would say, `Go to that pile of ashes and urinate on it.' When he would urinate on the ashes, a light, meaning the light of faith, would depart from him and would shine until it entered heaven. Then something black that appeared to be smoke would descend and enter his ears and the rest of his body, and this is Allah's anger. When he told the angels what happened, they would teach him magic. So Allah's statement,

﴿وَمَا يُعَلِّمَانِ مِنْ أَحَدٍ حَتَّى يَقُولاَ إِنَّمَا نَحْنُ فِتْنَةٌ فَلاَ تَكْفُرْ﴾

(But neither of these two (angels) taught anyone (such things) till they had said, "We are for trial, so disbelieve not (by learning this magic from us).)

Sunayd said that Hajjaj said that Ibn Jurayj commented on this Ayah (2:102), "No one dares practice magic except a disbeliever. As for the Fitnah, it involves trials and freedom of choice.''The scholars who stated that learning magic is disbelief relied on this Ayah for evidence. They also mentioned the Hadith that Abu Bakr Al-Bazzar recorded from `Abdullah, which states,

«مَنْ أَتَى كَاهِنًا أَوْ سَاحِرًا فَصَدَّقَهُ بِمَا يَقُولُ فَقَدْ كَفَر بِمَا أُنْزِلَ عَلى مُحَمَّدٍصلى الله عليه وسلّم»

(Whoever came to a soothsayer or a sorcerer and believed in what he said, will have disbelieved in what Allah revealed to Muhammad .)

This Hadith has an authentic chain of narration and there are other Hadiths which support it.