Does Emission of Semen Without Desire Break the Fast?
Question

Emission of Maniy (semen) with desire during Ramadan leads to spoiling the fast, but does emitting it for some other reason spoil the fast, as happened to me? – I was in an exam, and the invigilator started saying, “There are three minutes left,” and it happened to me because of the time pressure and panic; it was emitted without any deliberate action, I mean that it was involuntary. Did that spoil my fast? Do I have to do Ghusl?
Praise be to Allah.With regard to emission of Maniy (semen) that occurs when one is awake , if it occurs as a result of desire, then there are rulings that are connected to that: Ghusl becomes obligatory , and it spoils the fast. 
But if it is emitted without desire, because of sickness, cold and the like, then no rulings apply as a consequence of that, according to the view of the majority of jurists. 
Some of the jurists differentiate between the obligation to do Ghusl and the spoiling of the fast, such as the Shafi`is. They think that Ghusl is required because of this semen that was emitted without desire, but they do not think that it spoils the fast.
Ad-Dardir (may Allah have mercy on him) said in Ash-Sharh Al-Kabir (1/523): “… emission of semen when awake with normal feelings of pleasure [spoils the fast] …  but emission of semen without pleasure or without the normal feelings of pleasure [does not spoil the fast] …”
Ibn Qudamah (may Allah have mercy on him) said:
“If he masturbates, he has committed a forbidden action, but his fast is not spoiled unless he ejaculates . If he ejaculates, he spoils his fast, because it is akin to kissing in terms of provoking desire. But if he ejaculates without desire, such as one who emits Maniy or Madhiy because of sickness, he does not have to do anything, because it was emitted without desire, like urine, and because it was emitted involuntarily, and was not caused by any action on his part, so it is akin to a wet dream.” (Al-Mughni, 2/128)
In Hashiyat Qalyubi wa `Umayrah (2/74) it says: “Ejaculation that occurs involuntarily does not break the fast.” 
In conclusion, if emission of Maniy (semen) occurred involuntarily , and without pleasure, then it does not spoil the fast.
With regard to Ghusl, the view of the majority of jurists is that it is not required if the semen was emitted without desire. Nevertheless, if the person does Ghusl, that will be better and more prudent.
And Allah knows best.