The purpose of congregational prayer is unity.
Some scholars said: Rather, it is permissible for one to follow the other as an imam (1). If the prayer is one in which congregation is obligatory, then he must follow him and pray behind him. For each of them considers the other mistaken in light of his own independent judgment, while considering him correct in light of the latter’s own independent judgment. Thus, I believe that the imam is mistaken in turning south according to my own judgment; yet according to his independent judgment, I believe that he is correct, and that if he were to follow me, his prayer would be invalid.
They said: A comparable case is that of two men who have eaten camel meat: one of them holds that camel meat invalidates ablution, while the other holds that it does not. If one prays behind the other, then one of them considers the other’s prayer invalid; nevertheless, it is permissible for either of them to pray behind the other. They said: This is analogous to the present case. Believing that one is mistaken regarding the ruling is like believing that one is mistaken regarding the factual circumstance (2). The one who differs with me concerning the qiblah agrees with me on the ruling—namely, that facing the qiblah is a condition—but we differ concerning the factual circumstance: I believe that this is the qiblah, whereas he believes that the qiblah lies in another direction. Thus, there is no difference between my believing that this meat invalidates ablution and his believing that it does not invalidate it.
This view is closer to what is correct: namely, that it is permissible for one of them to pray behind the other despite their differing over the direction of the qiblah. The opposition in their directions does not prevent one from praying behind the other, just as when one prays behind the other inside the Ka'bah, while one faces the northern wall and the other faces the southern wall.