Praise be to Allah.
Comparing these two things is intrinsically false, and whatever is built on a false basis is also false, and this is due to a number of things:
The word ihtilaam (translated here as erotic dream) refers to what a person sees in his sleep, which includes a man seeing images of intercourse and imagining the sexual act in his sleep. This is something natural which all men and women see. There is nothing wrong with it and there is no sin on a person because of that. It was narrated in the hadeeth of Umm Sulaym that she asked the Prophet of Allaah (peace and blessings of Allaah be upon him) about a woman who sees in her dream what a man sees. The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “If a woman sees that she should do ghusl.” (Narrated by Muslim, al-Hayd, 469)
Erotic dreams are beyond a person’s control and he has no power to prevent them. Rather is a means of the body ridding itself of excess material that may harm it if it remains in the body. Hence sometimes a person may see something in his sleep, and sometimes he may not see anything but still experience nocturnal emissions. Hence it is not haraam. Allaah says (interpretation of the meaning):
“Allaah burdens not a person beyond his scope. He gets reward for that (good) which he has earned”
With regard to masturbation, it is haraam because it happens by a person’s intention and will. See the answer to question 329.
The same applies to looking at women, because this happens by a person’s choice and intention, and he does it deliberately. Hence it is not allowed.
Because a person is unable to prevent a sudden glance, he will not be brought to account for that, rather the sin is in following it with another glance. It says in the hadeeth: “O ‘Ali, do not follow one glance with another, for you are allowed the first but not the second.” (Narrated by al-Tirmidhi, al-Adab, 2701; classed as hasan by al-Albaani in Saheeh al-Tirmidhi, no. 2229). What is meant by “you are allowed the first” is if that does not happen intentionally, and “but not the second” means because it is done by your own choice, so it is a sin on you.
Allaah has commanded the believers to lower their gaze. Allaah says (interpretation of the meaning):
“Tell the believing men to lower their gaze (from looking at forbidden things), and protect their private parts (from illegal sexual acts)”
The Messenger of Allaah (peace and blessings of Allaah be upon him) also commanded likewise. It was narrated that Jareer said: “I asked the Messenger of Allaah (peace and blessings of Allaah be upon him) about a sudden look. He said, ‘Avert your gaze.’” (Narrated by Abu Dawood, al-Nikaah, 1836; classed as saheeh by al-Albaani in Saheeh Abi Dawood, no. 1880. Hence it is obligatory to obey the command of Allaah and His Messenger. Allaah says (interpretation of the meaning):
“And let those who oppose the Messenger’s (Muhammad’s) commandment (i.e. his Sunnah legal ways, orders, acts of worship, statements) (among the sects) beware, lest some Fitnah (disbelief, trials, afflictions, earthquakes, killing, overpowered by a tyrant) should befall them or a painful torment be inflicted on them”
What people should know and believe is that Allaah does not burden people with things that are too difficult for them or impose hardship upon them. He does not enjoin any impossible commands. This includes lowering the gaze, for it is within a person’s reach to obey this command.
But because the way to Paradise is lined with difficult things and the way to Hell is lined with whims and desires, Allaah has made this a test and a trial for His slaves. So whoever obeys the command of Allaah and keeps away from that which Allaah has forbidden, the consequences will be good for him and he will have a good Hereafter. And the converse also applies (i.e., one who goes against Allaah’s commands will have bad consequences).
Allaah has commanded us to lower our gaze and has forbidden us to look at women because of the great evil and mischief that result from that. For looking is the harbinger of zina (unlawful sexual relationships) – Allaah forbid. Hence it says in the hadeeth that Allaah has decreed for the son of Adam his share of zina, which will inevitably catch up with him, and the zina of the eyes is looking, the zina of the tongue is speaking; the heart wishes and hopes and the private parts confirm that or deny it.” (Narrated by al-Bukhaari, al-Qadar, 6122). So if a person lowers his gaze and refrains from looking at that which Allaah has forbidden, how could he be motivated to commit immoral actions? What the Muslim must do is to keep away from everything that may lead to immorality, whether that is looking at women, or thinking thoughts that provoke and increase desire. Whoever does those things will only make more worry and distress for himself, to no avail.
As the poet said:
“If you let your gaze wander, this will cause you a lot of heartache.
You will see things that you will desire but you are unable to acquire them, yet you are unable to bear that with patience.”
“How many looks have been fatal to the heart of the one who looked,
as fatal as an arrow, but with no bow and no string.”
And it was said that being patient in lowering one's gaze is easier than trying to put up with the pain that comes afterwards.
We ask Allaah to guide us all. And Allaah knows best. May Allaah bless our Prophet Muhammad.