The ruling on swimming when fasting depends on the following:
If the swimmer thinks it most likely that no water will enter his stomach through the mouth or nose, and he is a good swimmer and can guarantee that his fast will not be broken, then in that case there is nothing wrong with him swimming. The ruling is the same as that on doing ghusl when fasting. The scholars have stated that that is permissible even if it is just for the purpose of cooling down.
Al-Bukhaari (may Allaah have mercy on him) said: “Chapter on doing ghusl when fasting. Ibn ‘Umar (may Allaah be pleased with him) wetted his garment and put it on when fasting.”
Al-Sha’bi entered the hammam (bath) when fasting. And al-Hasan said: There is nothing wrong with the fasting person rinsing his mouth and cooling himself off … and Anas said: I have a tub which I keep immersing myself in when I am fasting.
Abu Bakr al-Athram narrated with his isnaad that Ibn ‘Abbaas entered the hammam when he was fasting, he and some of his companions, during the month of Ramadaan. Al-Mughni, 3/18
It says in Fataawa al-Lajnah al-Daa’imah (10/281):
It is permissible to swim during the day in Ramadaan, but the swimmer should take care to avoid letting water enter his stomach. End quote.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said:
There is nothing wrong with the fasting person swimming, and he may swim as he wants, and immerse himself in the water, but he must be careful to avoid letting water enter his stomach, as much as he can. This swimming will energize the fasting person and help him to fast, and whatever gives a person energy to carry out Allaah’s commands should not be disallowed, for it is something that makes it easy for people to carry out His commands. Allaah says in the verses on fasting (interpretation of the meaning):
“Allaah intends for you ease, and He does not want to make things difficult for you. (He wants that you) must complete the same number (of days), and that you must magnify Allaah [i.e. to say Takbeer (Allaahu Akbar: Allaah is the Most Great)] for having guided you so that you may be grateful to Him”
And the Prophet (peace and blessings of Allaah be upon him) said: “This religion is easy, and whoever overburdens himself in religious matter will not be able to continue in that way.” And Allaah knows best. End quote.
He also said:
There is nothing wrong with a fasting person diving into water or swimming in it, because that is not among the things that break the fast. The basic principle is that things are permissible unless there is evidence to show that they are makrooh or haraam. There is no evidence that swimming is makrooh or haraam, rather some of the scholars regarded it as makrooh lest anything enter the swimmer’s throat without him realizing it. End quote.
Fataawa Ibn ‘Uthaymeen, 19/284, 285
If he thinks it most likely that water will enter his stomach because of swimming, then it is not permissible for him to do this, and it is haraam for him to go swimming during the day in Ramadaan. The evidence for that is the report narrated from Laqeet ibn Sabirah (may Allaah be pleased with him) who said: I said: O Messenger of Allaah, tell me about wudoo’. He said: “Do wudoo’ well, make the water go between your fingers and toes, and go to extremes in rinsing the nose, unless you are fasting.” Narrated by Abu Dawood (142) and al-Tirmidhi (788), who said it is hasan saheeh. Classed as saheeh by Ibn Hajar and al-Albaani.
Imam Ahmad said that a fasting person may immerse himself in water if he does not fear that it will get into his ears.
Al-Hasan and al-Sha’bi regarded it as makrooh to immerse oneself in water, lest water get into the ears. al-Mughni (3/18).
Al-Adhra’i (one of the Shaafa’i fuqaha’) said:
If he knows that water usually enters his stomach when he immerses himself in water, and he cannot avoid it, it is haraam for him to immerse himself. End quote. Haashiyat al-Bujayrami (2/74).
The question now is: if he goes to extremes in rinsing his nose – and similarly if he immerses himself in water and swims during the day in Ramadaan – and water reaches his stomach without him intending it to, whether he thought it most likely that water would not enter his stomach or not – is he regarded as having broken the fast?
The scholars differed concerning that.
The first view is that of the majority of Hanafi, Maaliki and Shaafa’i scholars, which is that his fast is invalidated.
The second view is that it is not invalidated. This is the view of some of the Taabi’een, and is the view of the Hanbalis, and was the view favoured by Ibn ‘Uthaymeen (may Allaah have mercy on him). Al-Sharh al-Mumti’ (6/407).
See: al-Majmoo’ (6/338); al-Mughni (3/18).
You must also be careful to avoid showing the ‘awrah when swimming. Do not swim in a place where people uncover their ‘awrahs, and do not take lightly the issue of looking at the ‘awrahs of others.