The difference between mu‘jizah, karaamah (two types of miracles) and witchcraft
Question

                What is mu‘jizah, and what is the difference between it and karaamah on the one hand, and between it and witchcraft on the other?.
Praise be to Allah.Firstly: 
The mu‘jizah (miracle) is the extraordinary sign with which Allah supports His Prophets and Messengers, and challenges people. The karaamah is something extraordinary that Allah causes to happen at the hand of one of His close friends. There are many differences between the mu‘jizah and the karaamah, including the following: 
1. The mu‘jizah is meant to be done openly and be seen and known by many people, and the one for whom it is done (the Prophet) is enjoined to show it openly, whereas the karaamah is based on concealment and the one for whom it is done (the wali or close friend of Allah) is enjoined to conceal it.
2. The mu‘jizah may be accompanied by a challenge and claim of Prophethood, whereas the karaamah is not accompanied by any challenge or any claim of virtue or high status before Allah.
3.  The fruits of the mu‘jizah bring benefits to others, whereas the karaamah usually only benefits the one to whom it is given.
4. The mu‘jizah may be any extraordinary event; the karaamah can only be of a few types.
5. The mu‘jizah is only for the Prophets, whereas the karaamah is for the close friends of Allah.
6. The Prophets use their miracles (mu‘jizah) to establish proof against the mushrikeen, because their hearts are hard; the close friends of Allah (awliya’) use the karaamah to establish proof for themselves so that they will have peace of mind and certainty of faith, and will not be worried or anxious.
Quoted from a Master’s thesis entitled al-Wilaayah wa’l-Karaamah fi’l-‘Aqeedah al-Islamiyyah by Muhammad Khayr al-‘Umari. 
There are also a number of other differences between the mu‘jizah and witchcraft, including the following: 
1. The mu‘jizah is something extraordinary, i.e., it occurs contrary to the laws of nature and comes from Allah, may He be exalted. As for witchcraft, it occurs according to laws that the practitioner of witchcraft may learn.
2. The mu‘jizah results in nothing but good, whereas no good can come from witchcraft.
3. The mu‘jizah cannot be cancelled out, whereas witchcraft can be cancelled out or undone. It is well known that witchcraft can only be done by seeking the help of the devils and drawing close to them.
End quote from Dr. Ahmad al-‘Awaayishah, Muhaadaraat bi’th-Thaqaafah al-Islamiyyah, p. 174 
4. The mu‘jizah occurs at the hand of the Prophet, who is the best of people in knowledge, deeds and attitude, whereas witchcraft occurs at the hands of the practitioner of witchcraft, who is the worst of people in knowledge, deeds and attitude – people are put off by him and those who keep company with him.
5. There is no cause for the mu‘jizah, hence no one other than the Prophet can do anything like it. As for witchcraft, it has causes that are well-known, which are incantations that are spoken or written, and he makes use of the jinn in doing it. Anyone who learns that and does it will get what he wants from witchcraft. In the case of the mu‘jizah, it cannot be obtained by learning and experience.
See: al-Furooq by al-Quraafi, 8/116 
There follow some of the comments of the scholars on the differences between mu‘jizah, karaamah and witchcraft. 
Al-‘Allaamah as-Sa‘di (may Allah have mercy on him) said: 
The difference between the mu‘jizah and karaamah, and devilish extraordinary things that happen at the hands of magicians and charlatans is as follows: 
The mu‘jizah is that which Allah causes to happen at the hands of the Messengers and Prophets of extraordinary events with which they challenge the people, so that they will believe in the message with which Allah sent them and by means of which He supported them, such as the splitting of the moon and the sending down of the Qur’aan, which is the greatest mu‘jizah ever bestowed upon a Messenger, as well as the grieving of the palm tree stump (which the Prophet (blessings and peace of Allah be upon him) used as a minbar until a minbar was built for him), the springing up of water from between his fingers, and many other miracles. 
The karaamah is an extraordinary event that Allah causes to occur at the hands of His believing close friends (awliya’), such as knowledge, power, and so on, and such as the shade that used to come upon Usayd ibn al-Hudayr when he recited Qur’aan, and the shining of light for ‘Abbaas ibn Bishr and Usayd ibn Hudayr when they left the Prophet (blessings and peace of Allah be upon him), and when they separated there was light for each of them at the end of his whip. 
In order for it to be regarded as a karaamah, it is stipulated that the one at whose hand this miracle occurs should be adhering strictly to Islam and following sharee‘ah. If that is not the case, then these extraordinary things happen are the result of devilish work. Moreover, it should be noted that the fact that karaamah does not happen for some Muslims does not mean that they are lacking in faith, because karaamah only happens for certain reasons, such as the following: 
- To strengthen the person’s faith and make him steadfast. Hence many of the Sahaabah did not see any karaamah, because of the strength and absolute certainty of their faith.
- To establish proof against the enemy, as happened to Khaalid when he ate poison. He was besieging a fortress and they refused to yield until he ate the poison, so he ate it and then he conquered the fortress. A similar thing happened to Abu Idrees al-Khawlaani when he was met by al-Aswad al-‘Ansi in the fire and Allah saved him from that, because he needed that karaamah. We see something similar in the story of Umm Ayman when she set out to migrate to Madinah (Hijrah) and became extremely thirsty. She heard a sound above her and lifted her head, and she saw a bucket of water; she drank from it then it was taken away again.
The karaamah may be a test or trial; some people may be blessed by it and others may be doomed as a result. The one at whose hands it happens may be blessed if he gives thanks for it, or he may be doomed if he is filled with self-admiration and does not adhere to righteousness.
End quote from at-Tanbeehaat al-Lateefah fima Ahtawiyat ‘alayhi al-Waasitiyyah min al-Mabaahith al-Muneefah, p. 107 
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked: 
How can we differentiate between mu‘jizah, karaamah and kahaanah (sorcery)? 
He replied: 
The mu‘jizah is for the Prophets, the karaamah is for the close friends of Allah, the awliya’ of ar-Rahmaan, and kahaanah is for the close friends of the Shaytaan (awliya’ ash-shaytaan).  
Nowadays it is impossible for a mu‘jizah to occur, because the Messenger (blessings and peace of Allah be upon him) was the last of the Prophets. Karaamah happened at the time of the Messenger and may occur after his time, until the Day of Resurrection; it may occur at the hands of a righteous close friend of Allah (wali). If we know that the man at whose hand a karaamah occurred is a righteous man who fulfils his duties towards Allah and towards His slaves, then we know that it is indeed a karaamah. 
We should look at the man -- if this “miracle” comes from a kaahin (soothsayer) -- i.e., a man who is not righteous -- then we know that it comes from the devils; the devils sometimes help the sons of Adam to achieve what they want. 
End quote from Liqaa’aat al-Baab al-Maftooh (no. 84; question no. 8) 
And Allah knows best.