matters need not be established through the general, universal evidence of Islamic law; rather, they are known through specific evidence that points to them. One means of this is “inspiration”: Allah may inspire some of His servants with knowledge of the circumstances of a particular property or person, even when there is no outward evidence accessible to others.
The story of Moses and al-Khidr falls into this category. It contains no violation of Allah’s Law, for no one—neither a prophet nor a friend of Allah—may ever violate His Law. Rather, it involves knowledge of a particular case in which a hidden circumstance makes what al-Khidr did obligatory under the Law. This is like someone who enters a house and takes the property inside, knowing that its owner has given him permission, while others do not know this. Likewise, someone might find a stray animal and take it without announcing that he has found it, knowing that it was brought as a gift for him; and there are other similar examples. Such things are common among those who receive genuine inspiration.
(The second type) is the opposite: they follow their desires rather than Allah’s command. They do and command only what their desires incline them to love, and they refrain from and forbid only what their desires incline them to hate. These are the worst of creation.
Allah Most High says:
“Have you seen the one who takes his own desire as his god? Will you then be a guardian over him?”
Al-Hasan said: “This is the hypocrite: whatever he desires, he pursues.”
And Allah Most High says: