This website is under review. Do not rely on it for final rulings.
Machine translation
Question
I used to practise masturbation and I do not know how many prayers I performed while in a state of impurity, due to my ignorance that it invalidates the prayer. What should I do?
Answer
All praise is due to Allah, and peace and blessings be upon the Messenger of Allah, and upon his family and companions. To proceed:
First, you must repent to Allah from this bad habit. If it resulted in the emission of madhi, you are obliged to wash the part of your body and clothing that was touched by it, and you are obliged to perform wudu when you wish to pray. If it resulted in the emission of semen, you are obliged to perform ghusl from major impurity. If none of that resulted, then nothing is obligatory upon you in terms of purity. Accordingly, if your masturbation resulted in the emission of madhi or semen, and you did not do what is required of you because of that and prayed, then that prayer is invalid and you must repeat it. If you know the number of prayers you performed in that state, make them up according to that number; if you do not know the number, pray a number that you are confident will fulfil your obligation, and increase your voluntary prayers and seeking of forgiveness. If your masturbation did not result in any of what was mentioned, then your prayer is valid, but you must repent to Allah the Exalted from masturbation in every case, for it is forbidden, and refer to the fatwa:7170. And Allah knows best.
الحمد لله، والصلاة والسلام على رسول الله، وعلى آله وصحبه، أما بعد:
فعليك أولا أن تتوبي إلى الله من ممارسة هذه العادة السيئة، وإن ترتب عليها خروج مذي لزمك غسل المحل الذي أصابه من بدنك وملابسك، ولزمك الوضوء إذا أردت أن تصلي. وإن ترتب عليها خروج مني لزمك الغسل من الجنابة، وإن لم يترتب عليها شيء من ذلك، فلا يلزمك شيء من حيث الطهارة. وعلى ذلك، فإن ترتب على ممارستك للعادة السرية خروج مذي أو مني، ولم تقومي بما يلزمك من جراء ذلك وصليت، فإن صلاتك تلك باطلة، وعليك إعادتها، فإن علمت عدد الصلوات التي صليتها بتلك الحالة، فاقضيها على حسب ذلك، وإن جهلت العدد فصلي عدداً تحتاطين به لعبادتك، وأكثري من النوافل والاستغفار. وإن كانت ممارستك للعادة السرية لم يترتب عليها شيء مما ذكر، فصلاتك صحيحة، وعليك التوبة إلى الله تعالى من ممارسة العادة السرية على كل حالٍ، فإن ممارستها محرمة، وراجعي الفتوى: 7170. والله أعلم.