Short answer
No. An x-ray, CT scan, MRI, ultrasound over the skin or ECG does not break the fast, because nothing enters the body through an opening. Contrast given by injection does not break it either, but a contrast drink, an enema or a scope with gel or fluid usually does. Ask a mufti about any internal procedure.
Imaging that only passes rays, magnetic fields or sound through the body does not break the fast. Anything swallowed, such as a contrast drink, breaks it. A tube or scope that enters the body through an opening usually breaks the fast when it carries liquid, gel or medicine with it; the details need a mufti. A patient who needs such a test is excused and makes up the day.
The four schools agree on this.
Explanation
The fast is broken by something reaching the stomach or body cavity through the mouth, nose or another open passage. X-rays, CT scans and MRI pass rays or magnetic fields through the body, and nothing physical goes in, so they do not touch the fast. An ultrasound done over the skin, with gel on the outside, is the same, and so is an ECG. Contemporary scholars of the four schools agree on this.
Contrast. Some scans need a contrast agent. Injected into a vein, it is like any injection and does not break the fast in the view of most Hanafi muftis: see injections. If you have to drink it, it breaks the fast like any drink.
Internal procedures. Tests that put a tube or scope inside the body are different. An endoscopy through the mouth, a colonoscopy and its bowel preparation, a barium enema and internal ultrasounds involve liquids, gels or instruments entering through an opening, and many of them break the fast in the Hanafi school. See suppositories and enemas, and ask a mufti about your exact test.
Practical advice:
- Ask for an appointment after iftar, or early before dawn, if possible.
- If the test must be in the day and will break the fast, you are excused as a patient: have it and make up the day.
- A blood test before a scan does not break the fast. See blood tests.
Ask a mufti about your own case. This answer explains the general ruling. When the details of your situation matter, as they do here, ask a qualified mufti and give them the full facts. Where to ask a scholar.
The evidence
Quran, Surah Al-Baqara 2:185
شَهْرُ رَمَضَانَ ٱلَّذِىٓ أُنزِلَ فِيهِ ٱلْقُرْءَانُ هُدًۭى لِّلنَّاسِ وَبَيِّنَٰتٍۢ مِّنَ ٱلْهُدَىٰ وَٱلْفُرْقَانِ ۚ فَمَن شَهِدَ مِنكُمُ ٱلشَّهْرَ فَلْيَصُمْهُ ۖ وَمَن كَانَ مَرِيضًا أَوْ عَلَىٰ سَفَرٍۢ فَعِدَّةٌۭ مِّنْ أَيَّامٍ أُخَرَ ۗ يُرِيدُ ٱللَّهُ بِكُمُ ٱلْيُسْرَ وَلَا يُرِيدُ بِكُمُ ٱلْعُسْرَ وَلِتُكْمِلُوا۟ ٱلْعِدَّةَ وَلِتُكَبِّرُوا۟ ٱللَّهَ عَلَىٰ مَا هَدَىٰكُمْ وَلَعَلَّكُمْ تَشْكُرُونَ ﴿١٨٥﴾
The month of Ramadhan [is that] in which was revealed the Qur'an, a guidance for the people and clear proofs of guidance and criterion. So whoever sights [the new moon of] the month, let him fast it; and whoever is ill or on a journey - then an equal number of other days. Allah intends for you ease and does not intend for you hardship and [wants] for you to complete the period and to glorify Allah for that [to] which He has guided you; and perhaps you will be grateful.
Medical needs are met with ease, and a broken day is simply made up.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Kitab al-Sawm, chapter on what breaks the fast and what does not. What reaches the body cavity through an open passage breaks the fast; what does not enter, or is dry and does not stay inside, does not.
- al-Hidaya, Kitab al-Sawm, chapter on what requires qada and kaffarah. Medicine reaching the inside through an opening breaks the fast, with qada and no kaffarah.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.