Praise be to Allah.
The most correct scholarly view is that swallowing sputum does not invalidate the fast, as was previously explained in fatwa no. 172499. This does not contradict the fact that fasting is invalidated by swallowing anything, even if it is not food, such as pebles and the like.
It says in al-Haawi al-Kabeer (3/456): ash-Shaafa‘i (may Allah be pleased with him) said: If he swallows a pebble or something that is not food, or uses a suppository, or treats a wound and (the medicine) reaches his stomach, or he uses snuff and it reaches the inside of his head, then he has broken the fast if he remembered (that he was fasting), but there is no blame on him if he forgot.
Al-Maawardi said: And that is the case if he swallows food or drink or something that is neither food nor drink, such as a dirham (silver coin) or a pebble, or a walnut or an almond, then he has broken the fast by doing any of these things, and he must make up that day if he did it deliberately, remembering that he was fasting; but if he did it because he had forgotten, then his fast remains valid. End quote
This issue has been discussed previously in fatwa no. 78479
The reason why there is no contradiction is that sputum comes from inside the body and it is part of his physical being, so if a person swallows it, it cannot be said of him that he has swallowed something from outside his body. This is unlike the case with a stone and the like; the one who takes it and swallows it has taken something from outside his body, so his fast is invalidated thereby.
Ibn Habeeb said: Whoever clears his throat then swallows his sputum after it reaches the edges of his tongue, there is no blame on him, but it is not appropriate, because sputum is not food or drink, and it originates inside the head. Al-Baaji said: The point that Ibn Habeeb was trying to make is that he did not pick it up from the ground; rather he let it collect in his mouth in a normal manner, like saliva; otherwise it is makrooh to swallow it because it is possible to spit it out, unlike saliva.
End quote from at-Taaj wa’l-Ikleel (2/426)
Shaykh Muhammad al-Hasan ad-Daddu ash-Shinqeeti says: What is in the mouth is viewed like anything else inside the body according to the more correct view, therefore it does not become najis (impure) unless it comes out of the mouth. With regard to that which a person did not put in his mouth from the outside, rather it came from inside the mouth or is part of his physical being, the correct view is that it does not invalidate the fast. Saliva, sputum and the like are things that come from inside the body; hence that does not invalidate the fast, because they are not nourishment from outside. This is the more correct opinion.
End quote from the following link:
Sputum that is in the nose as a result of sniffing with the nose, then he lets it get into his mouth, then he swallows it, does not invalidate the fast according to the more correct view. It says in Tabyeen al-Haqaa’iq Sharh Kanz ad-Daqaa’iq (1/324): If he sniffs back the sputum from his nose until he lets it get into his mouth, and swallows it deliberately, that does not invalidate the fast. End quote.
In al-Bahr ar-Raa’iq Sharh Kanz ad-Daqaa’iq (2/294) it says: If sputum enters the fasting person’s nose from inside his head, then he sniffs it back and it enters his throat as a result of a deliberate action on his part, there is no blame on him, because it is the same as his saliva; unless he puts it in his hand then swallows it. In that case he has to make up that day. And in az-Zuhayriyyah it says that the same applies to sputum and spittle that comes out of his mouth or nose, then he sniffs it back, iIt does not invalidate his fast. End quote.
However we have previously pointed out that sputum is something that is usually regarded with disgust, so he should not swallow it if he is able to expel it.
More than one of the scholars have pointed out that one should take into consideration the view that says that doing so invalidates the fast, because it is not difficult to pay attention to that.
Al-‘Allaamah ash-Sharanbilaali al-Hanafi (may Allah have mercy on him) said:
Concerning the evidence, Ibraaheem was asked about one who swallows his sputum.
He said: If it is less than a mouthful, it does not invalidate the fast, according to consensus [i.e., among the Hanafis].
But if it fills his mouth, then it does invalidate his fast, according to Abu Yoosuf; but according to Abu Haneefah it does not invalidate his fast, but he should expel the sputum so that it does not invalidate his fast, according to the view of Imam ash-Shaafa‘i, as was pointed out by al-‘Allaamah Ibn Shahnah, so that his fast will be valid according to scholarly consensus, because he is able to expel it.
End quote from Maraaqi al-Falaah Sharh Noor al-Eedaah (246)
And Allah knows best.