Answered by Mufti Yusuf Mullan
Question: What do I do if more sperm comes out after ghusl, but after I prayed?
Answer: In the name of Allah, ar-Rahman, ar-Raheem and may His abundant blessings and most most perfect of peace be showered on the Best of Creation.
The ruling regarding this will differ depending on whether excessive walking, using the toilet, or sleep occurred or not between the completion of the ghusl and the exiting of the sperm.
If any of these took place then both the ghusl and prayer offered will remain valid. However, because something has come out of the private parts, a new wudu will be need.
If none of these three things took place [i.e. significant walking, using the toilet, or sleep] then a new ghusl will be obligatory.
As for the prayer which was offered in this state, the fuqaha mention that because the prayer itself was offered with a sound state of purity, it would be valid given that the ghusl was invalidated after the prayer.
In the Hanafi school, in order for the ejaculation to nullify ritual purity, it must be accompanied with sexual gratification (shah-wah) at the time of leaving it’s place of origin (i.e. the loins). Once orgasm has begun and based on it ejaculate exists from the penis, ritual purification will be nullified. According to the stronger opinion within the school, forceful exiting in spurts is not a condition provided that the initial cause was orgasm and sexual gratification (and not lifting some heavy object etc.). Given this, semen which remained in the passageway and exited after the completion of ghusl will require that the ghusl be repeated. However, when sleep, urinating or excessive walking occurs after the bath and before the exiting of the semen, due to these movements cleaning the passageway and halting the dripping of all semen, any semen to exit thereafter will not be attributed to the initial gratification. In the latter case, owing to absence of sexual gratification, ritual purity will remain intact. [Ibn Abidin, Radd al-Muhtar, 1.160]
And Allah knows best.