Zaid Alsalami, Shaykh Dr Zaid Alsalami is an Iraqi born scholar, raised in Australia. He obtained a BA from Al-Mustafa University, Qom, and an MA from the Islamic College in London. He also obtained a PhD from... Answered 1 year ago

Bismihi ta'ala

Once you enter into the obligatory prayer, it becomes haram for you to break it. Unless of course there is something more wajib for you to do, like saving a life, or you missed out on one of the pillars of salat, or the other exemptions. 

As for the situation of having to go to the toilet, if one is able to hold on until their prayer is finished, then they should do so, and if not, due to fear of getting themselves najis, then they can go and relieve themselves. 

However, as is known, it is makruh to commence prayer in the first place while one is in need of going to the toilet, which is why one should first go to toilet, do wudhu and then pray.

And Allah knows best.