What is the ruling if, whilst having intercourse with his wife, a man imagines that she is some other woman and gets pleasure from that?.
What this man is doing is something that the scholars have stated is haraam, because even if he is only having intercourse with his wife, he is imagining himself committing zina and feeling pleasure as a result.
Ibn al-Haaj al-Maaliki (may Allaah have mercy on him) said:
A man should stay away from such thoughts and from this abhorrent characteristic which unfortunately is widespread, which is that when a man sees a woman he likes, he goes to his wife but he imagines that woman whom he has seen. This is a kind of zina, because our scholars said concerning one who takes a glass of water and imagines that it is wine that he is drinking, that that water becomes haraam for him. What is mentioned does not apply only to men, rather women are included in it too and that is even worse, because usually women nowadays go out and look at people, and if a woman sees someone whom she likes, she may keep thinking of him, then when her husband has intercourse with her she imagines that image which she has seen, so both of them may come under the heading of zina. We ask Allaah to keep us safe and sound. End quote.
Al-Madkhal, 2/194, 195
Ibn Muflih al-Hanbali (may Allaah have mercy on him) said:
Ibn ‘Aqeel said – and he emphasized the prohibition in al-Ri’aayah al-Kubra: If, when he is having intercourse with his wife, he imagines the image of another woman or a male, then he is sinning. End quote.
Wali al-Deen al-‘Iraaqi (may Allaah have mercy on him) said:
If he has intercourse with his wife but in his mind he is having intercourse with someone who is forbidden for him, and he imagines in his mind that he is having intercourse with that forbidden image, that is haraam for him, and that is because he is imagining himself committing a haraam action. End quote.
Tarh al-Tathreeb, 2/19
And Allaah knows best.