All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Having a wet dream during the daytime of Ramadan does not affect the validity of fasting because the pen of recording deeds is lifted from the sleeping person; i.e. he is not held accountable for his deeds because he has no way to avert what he encounters during his sleep. However, he should make ghusl once the time of the prayer comes, based on the words of Allah, the Almighty, (what means): {Do not approach prayer while you are in a state of janabah [state of major ritual impurity] until you have washed [your whole body].} [Quran 4:43]
If semen comes out intentionally through masturbation, kissing, or lustful contact (with the wife), fasting is invalidated and one must make up for that day.
Ibn Qudaamah said about the one who kissed and thereupon discharged semen while he was fasting:
The second case is when he discharges semen: his fast is broken, a fact over which there is no difference of opinion, to the best of our knowledge, because the two reports refer to that, as we have already mentioned. Furthermore, he discharged semen through contacting, and thus it is similar to ejaculation through sexual intercourse but without penetration.
About the one who masturbates and then discharges semen, he said:
If one masturbates with his hand, he has committed a prohibited act, yet his fast is not invalidated by it unless he discharges semen. If he discharges semen his fast is invalidated because it is similar to the kiss in arousing sexual desire.
Similarly, if the discharge of semen results from looking repeatedly (at what arouses the desire), it invalidates fasting according to the predominant opinion in the sight of some scholars.
If the discharge of semen results from having arousing thoughts only, it does not invalidate fasting. The evidence is the statement of the Messenger of Allah, sallallaahu ‘alayhi wa sallam, who said, “Verily, Allah has forgiven the people of my Ummah (community) the evil thoughts which occur to their minds as long as they do not execute them or speak of them.” [Al-Bukhaari and Muslim]
Those are the states of the discharge of semen and their effect on the fast of the one who is competent for religious assignment. It is due on the one who discharges semen in any of those cases to make ghusl when the time of prayer comes, based on what has previously been mentioned.
Allah knows best.