What can be done to be protected from sorcery and magic? The short answer is…
Islam is a religion which strictly prohibits magic, which is considered as one of the biggest sins. It is emphasized in the Holy Qur’an that those who practice sorcery will have no blessings in the hereafter and people should take refuge in Allah against those who practice it (Baqarah, 2/102; Falaq, 113/4). Prophet Muhammad (saw) regarded practice of sorcery among the seven major sins (Bukhari, Wasaya, 23; Muslim, Iman, 145).
In the period of ignorance, sorcery/magic was highly common. Some practices such as incantation, soothsaying, interpreting stars, consulting to fortune-telling arrows, and breathing on ropes by knotting them used to be performed. Under the influence of this situation, the polytheists went so far as to claim that the Qur’an was a work of magic (Sad, 38/4; Dhariyat, 51/52).
It is against Islamic faith to believe that the sorcerers know everything and that there is nothing they cannot achieve. Therefore, some Muslim scholars rejected magic on the grounds that it is a trick and nonsense which is not real. (See. Jassas, Ahkamu’l-Qur’an, I, 50; Nawawi, Rawda, IX, 128, 346).
The most effective solution against sorcery and magic is to take refuge in Allah and trust Him. Prophet Muhammad (saw) recited chapters of Nas and Falaq along with Ayat al-Kursi continuously by taking refuge in Allah against all kinds of evil. (Bukhari, Wakala, 10; Fadhail al-Qur’an, 10; Tirmidhi, Fezailu’l-Qur’an, 3). Moreover, he recited the following invocation in order to protect his grandchildren Hasan and Husayn (ra) from evil eye, magic, and similar negativities:
أَعُوذُ بِكَلِمَاتِ اللّٰهِ التَّامَّةِ مِنْ كُلِّ شَيْطَانٍ وَهَامَّةٍ وَمِنْ كُلِّ عَيْنٍ لاَمَّةٍ
“O Allah! I seek refuge with Your Perfect Words from every devil and from poisonous pests and from every evil, harmful, envious eye.” (Bukhari, Ahadith al-Anbiya, 10; Ibn Majah, Tibb, 36)
Besides this, it is permissible to recite Qur’an and make dua for people who think they are exposed to magic if they consult to trustable people by expecting that Allah will heal them. In the decision dated 28 September 1979 and numbered 1883 of the High Board of Religious Affairs, it was declared that it is permissible to recite Qur’an and the duas on patients with the hope that Allah will heal them and that it is prohibited in Islam to deceive public and claim curing by breathing in order to foretell the future.
Source: Presidency Of Religious Affairs The Turkey, High Board of Religious Affairs FATWAS