Praise be to Allah.
Can you gargle while fasting?
There is nothing wrong with a fasting person rinsing his or her mouth with water, or with water and salt, especially if there is a need to do that, such as reducing pain etc., subject to the condition that s/he be very careful not to let anything reach the stomach. If anything reaches the stomach by mistake, there is no sin on them and their fast is still valid.
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said:
“If a gnat flies into the mouth of a fasting person or something enters his mouth without him wanting it to, or he rinses his mouth or nose and some water enters his stomach without him meaning it to, then his fast is still valid and he does not have to make it up.” (Majalis Shahr Ramadan, 15)
Can you rinse your mouth while fasting?
And he was asked about rinsing the mouth when it is very hot – does that invalidate the fast?
“The fast is not invalidated by rinsing the mouth while fasting , because the mouth comes under the same ruling as the outside of the body. Hence the fasting person may rinse his mouth whilst fasting and that does not break his fast. Moreover, rinsing the mouth is obligatory in wudu , so if the mouth did not come under the same ruling as the outside of the body, washing it would not be obligatory in wudu. And rinsing the mouth when it becomes dry because of intense heat is something that makes fasting easier. It was narrated that the Prophet (peace and blessings of Allah be upon him) used to pour water over his head because of thirst if it was intensely hot when he was fasting. This was narrated by Abu Dawud (2365) and classed as sahih by al-Albani.
Ibn ‘Umar (may Allah be pleased with him) used to soak his garment and put it on when fasting, to cool himself down. And Anas ibn Malik (may Allah be pleased with him) had a cistern which he would fill with water and bathe in it when he was fasting. All of this indicates that doing things to make fasting easier for a person is permissible and there is no sin in it. But the one who rinses his mouth should be careful to avoid letting the water reach his stomach because that is a serious matter. But if water reaches his stomach in this case without him meaning it to, then there is nothing wrong with that.” (Majmu’ al-Fatawa, 19)
The two reports from Ibn ‘Umar and Anas were narrated by al-Bukhari in a mu’allaq report in his Sahih.
And Allah knows best.