Answered by Ustadh Tabraze Azam
Question: Assalamu ‘alaykum wa rahmatullahi wa barakatuh.
What must one do if an urgent need to pass wind or a nullifying element happens after the tashahhud in the last sitting when you pray behind an imam or praying alone?
Answer: Wa alaikum assalam wa rahmatullahi wa barakatuh,
I pray that you are in the best of health and faith, insha’Allah.
(1) If you pass wind unintentionally, or the prayer is nullified by some manner, you should go and perform the ablution (wudu) and repeat the prayer.
(2) If you have an urge to pass wind, you should likewise break the prayer, perform wudu, and then repeat your prayer. However, if you suffer from misgivings, the time is short, or you can ignore it, complete your prayer.
See also: What Should I Do If I Have the Urge to Pass Wind or Relieve Myself During Prayer? and: A Reader on Waswasa (Baseless Misgivings)
And Allah alone gives success.
Checked & Approved by Shaykh Faraz Rabbani.