Question:
Does one have to pay kaffarah if fasting in Ramadan and breaking the fast by masturbating?
Answer:
Wa alaykum salam wa rahmatuLlahi wa barakatuHu,
Masturbation is unlawful. Invalidating the fast by masturbating is a sin. One must repent to Allah. If such a mistake was made, then one must firmly resolve to never again do the same.
If one masturbates until ejaculating, then that fast day is invalidated. Therefore, it must be made up after Ramadan. There is no major expiation in this case. (al-Minhaj al-Qawim v. 2, p. 191; Mughni al-Muhtaj 2/178)
And Allah knows best.
Shafiifiqh.com Fatwa Dept.