The World Federation One Stop Fiqh

Ruling 1257

If a person realises that he has performed a prayer before its prescribed time, he must perform it again; and if its time has expired, he must make it up. If he realises that he performed it with his back to qibla or had turned ninety degrees or more [away from qibla], in the event that its time has not expired he must perform it again. However, if its time has expired, then in the event that he was uncertain or was ignorant about the rule, it is obligatory for him to make it up; otherwise, it is not. If he realises that he had turned less than ninety degrees, and he did not have a legitimate excuse for turning away from qibla for example, he was searching for the direction of qibla, or he was negligent in learning the ruling – then based on obligatory precaution, he must perform the prayer again, irrespective of whether there is time or not. However, if he did have a legitimate excuse, it is not necessary for him to perform the prayer again.