All praise is due to Allah, and peace and blessings be upon the Messenger of Allah.
Miracles, karāmāt (miraculous honors granted by Allah to His righteous servants), and magic may all involve extraordinary events that go beyond the ordinary course of nature. However, they differ fundamentally in their source, purpose, and ruling.
A miracle is an extraordinary event that Allah causes to occur at the hands of one of His prophets or messengers as proof of the truthfulness of his message and as evidence against the people. It is accompanied by the claim of prophethood and serves as a challenge that others cannot match.
A karāmah is an extraordinary event that Allah grants to one of His righteous servants as an honor, to strengthen his faith, or to fulfill a legitimate religious benefit, without any claim to prophethood or challenge.
Receiving a karāmah is not a condition for being one of Allah's righteous allies (awliyā'). Many of the greatest awliyā' never had any visible karāmah.
Magic (sihr) consists of prohibited practices that a magician learns and performs, often through the assistance of devils, magical incantations, talismans, and acts of shirk (associating partners with Allah). It is one of the gravest major sins. It is neither a karāmah of the righteous nor a miracle of the prophets.
Among the most important differences are:
The differences include:
The criterion is the condition of the person through whom these extraordinary events occur.
If the person adheres to the Qur'an and the Sunnah, fulfills the obligatory duties, and avoids what Allah has forbidden, then what appears at his hands is, in principle, a karāmah from Allah.
However, if the person is known for shirk, religious innovations, magic, or مخالفة the Islamic law, then what appears at his hands is not a karāmah but one of the satanic deceptions by which Satan misleads his followers.
A miracle is exclusive to the prophets as proof of their message. A karāmah is exclusive to Allah's righteous servants as an honor from Him. Magic is a prohibited practice based on seeking the help of devils and using false means. The criterion for distinguishing a true karāmah from satanic phenomena is the person's adherence to the Qur'an, the Sunnah, and obedience to Allah.
And Allah knows best.