As for scholarly consensus, the Muslims are unanimously agreed that facing the qiblah in prayer is obligatory. (1)
The wisdom behind this is that a person directs his body toward something venerated by Allah’s command—the Sacred House—just as he directs his heart toward his Lord in heaven. Thus, there are two directions: a direction of the heart toward Allah Most High, and a bodily direction toward His House, which one has been commanded to face and venerate. There is no doubt that the obligation to face the qiblah manifests the unity of the Muslim ummah in a way that is evident to all. Were it not for this, people in a single mosque would pray in different directions: one toward the south, another toward the north, a third toward the east, and a fourth toward the west. The rows in congregational prayer might even become impossible to form. But when they all face one direction, this becomes one of the greatest causes of harmony.
The Messenger of Allah, may Allah bless him and grant him peace, used to pray toward Jerusalem, with the Ka‘bah between him and Jerusalem, (2) so that he would stand