Does Gastroscopy Break the Fast?
Question

Does having a gastroscopy invalidate the fast?
Praise be to Allah.What is gastroscopy?
The gastroscope is a medical instrument that is inserted into the stomach via the mouth, and is used either to take a picture of the stomach or to take a sample for examination, or for other medical purposes, then after the procedure is complete, the instrument is removed via the mouth. 
Does gastroscopy break the fast?
The scholars differed as to whether, if something reaches the stomach, it invalidates the fast in all cases, whether it provides nourishment or not, or does it not invalidate the fast if it does not provide nourishment? 
Three madhhabs are of the view that the fast is broken by everything that enters the stomach: the Malikis, the Shafi`is and the Hanbalis. 
Based on that, this gastroscopy does invalidate the fast. 
The Hanafis agreed with them that everything that reaches the stomach invalidates the fast, but they stipulated that it should remain in the stomach. 
Based on that, gastroscopy does not invalidate the fast, because it does not remain in the stomach, rather it is removed once the procedure is completed. (See: Tabyin al-Haqaiq by al-Zayla’i (1/326); al-Majmu’ (6/317); al-Sharh al-Kabir (7/410); Sharh Muntaha al-Iradat (1/488); Bidayah al-Mujtahid (2/153).
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) was of the view that the fast is not broken unless a nourishing substance reaches the stomach. He (may Allah have mercy on him) said: 
“The more correct view is that the fast is not broken by swallowing something that does not provide nourishment, such as swallowing a pebble.” (Majmu’ al-Fatawa, 20/528) 
Based on this view, this gastroscopy does not invalidate the fast, and this view is more likely to be the correct one, because the text only indicates that eating and drinking spoil the fast. Allah says (interpretation of the meaning): 
“and eat and drink until the white thread (light) of dawn appears to you distinct from the black thread (darkness of night), then complete your Sawm (fast) till the nightfall.” [al-Baqarah 2:187]
The gastroscope is neither food nor drink, and is not akin to food or drink, because the body does not benefit from it and is not nourished by it. 
But, if any kind of greasy substance is put on the gastroscope to make it easier to insert it into the stomach, or some saline solution is introduced via the gastroscope to clean it and make it easier to take images, then the fasting person’s fast is invalidated when this substance reaches the stomach, because the body will absorb it and be nourished by it, so it is like food and drink. 
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said in al-Sharh al-Mumti’ (6/370, 371) – when explaining that everything that reaches the stomach invalidates the fast according to the madhhab of Imam Ahmad – : If a person has a gastroscope inserted and it reaches the stomach, then this breaks the fast [i.e., according to the Hanbali madhhab]. But the correct view is that it does not break the fast unless there is any grease or the like on the gastroscope that may reach the stomach via the gastroscope. In that case it breaks the fast, and it is not permissible to use it during an obligatory fast except in case of necessity. End quote. 
In a statement of the Islamic Fiqh Council it says: 
“The following things are not regarded as breaking the fast: … gastroscope if it is not accompanied by introduction of fluids (solutions) or any other substance.” (Majallat al-Majma’, 10/2/453-455) 
To sum up, if the gastroscope is inserted into the stomach without introducing any other substances, then it does not break the fast, but if some greasy substance or anything else is introduced with it then it does invalidate the fast. (See, Mufsidat al-Siyam al-Mu’asirah by Dr. Ahmad al-Khalil, p. 39-46)
For more, please see these answers: 8652 , 95062 , 38205 , and 37918 . 
And Allah knows best.