Reference: Fataawa al-Lajnah ad-Daa.imah lil-Buhooth al-‘Ilmiyyah wal-Iftaa. – Volume 11, Page 244, Question No.4 of Fatwa No.11935
Question: In Makkah al-Mukarramah, whilst performing the tawaaf al-wadaa’ and after I had made five circuits around the Ka’bah I felt some movement in my backside, so Iblees began whispering to me that I had passed wind but I did not adhere to his whispering because I did not feel that I had passed any wind from my anus, and I had completely lost the sense of smell, so I sought refuge in Allaah and put my faith in Allaah and continued performing the tawaaf and then [upon completion] performed the two rak’ah’s [of prayer]. So is there anything in this or is there anything upon me?
Response: The basic rule is that you remain in the state of purification, as the occurrence of doubt as to whether you passed wind does not nullify your state of purification [until you are absolutely sure], so your tawaaf and your prayer afterwards is correct/sound, ]in shaa.-Allaah].
And with Allaah lies all success and may Allaah send prayers and salutations upon our Prophet ﷺ and his family and his companions.