All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ʻalayhi wa sallam, is His slave and Messenger.
This action has no effect on the marriage bond; the wife is not declared unlawful to the husband because of his looking lustfully at his mother-in-law or having sexual fantasies about her. So he should disregard such doubts about his marriage, but he must repent to Allaah and resolve never to do this again in the future, especially given that his mother-in-law is his mahram (unmarriageable to him), and that masturbation itself is prohibited. Please, refer to fatwa 86527 about the conditions of sincere repentance and fatwa 81150 about the religious ruling on masturbation.
It should be noted that the Hanafi scholars who say that lustful looks (of a man to his wife's female descendants and ascendants) causes prohibition of marriage limit this ruling to looking at the private parts, and specifically inside the vagina. Tabyeen Al-Haqaai'q reads, “The criterion in establishing the prohibition of marriage because of lustful looks is looking at the inside of the woman's vagina (with lust)…”
Allaah knows best.