144قَدْ نَرَىٰ تَقَلُّبَ وَجْهِكَ فِى ٱلسَّمَآءِ ۖ فَلَنُوَلِّيَنَّكَ قِبْلَةً تَرْضَىٰهَا ۚ فَوَلِّ وَجْهَكَ شَطْرَ ٱلْمَسْجِدِ ٱلْحَرَامِ ۚ وَحَيْثُ مَا كُنتُمْ فَوَلُّوا۟ وُجُوهَكُمْ شَطْرَهُۥ ۗ وَإِنَّ ٱلَّذِينَ أُوتُوا۟ ٱلْكِتَـٰبَ لَيَعْلَمُونَ أَنَّهُ ٱلْحَقُّ مِن رَّبِّهِمْ ۗ وَمَا ٱللَّهُ بِغَـٰفِلٍ عَمَّا يَعْمَلُونَ
[144] We have seen you (O Muhammad), turning your face over and over again towards Heaven. Now, therefore, We turn you towards the giblah that you like best: so turn your face towards the Masjid Haram. Henceforth, wheresoever you may be, turn your face at prayer towards it.146 The people who were given the Book know it well that the commandment (about the change of giblah) is in fact from their Lord, and is based on the Truth, but Allah is not unaware of what they are doing (in spite of this)
146This is the commandment for the change of the giblah, which was enjoined in Rajab or Sha'ban, A.H. 2. When this was revealed, according to Ibn Sa'd, the Holy Prophet was leading the Zuhr (early afternoon) prayer in the house of Bishr bin Bara' bin Ma'rur where he had gone in response to an invitation. This verse was revealed when he had gone through half of the prayer. lie at once turned his face towards the Ka'bah during the prayer and those who were saying their Prayer following his lead did the same. Afterwards it was announced publicly in Madinah and its suburbs that the giblah had been changed. Bara' bin Azib says that at one place this announcement was heard at a time when the people had bent down in the Prayer. But when they heard the commandment, they turned about in the same posture towards the Ka'bah. Anas bin Malik says that the people of Bani Salamah heard of the change of the qiblah next morning at a time when they had already gone through half of the Prayer. As soon as they heard the announcement: "Beware, the giblah has been changed to the Ka'bah," the whole congregation turned about towards the Ka`bah.
In this connection, it should also be kept in mind that the Holy Temple at Jerusalem is to the north of Madinah and the Ka`bah at Makkah to the south of it. The Imam (who led the Prayer) must have walked to the rear of the congregation, who had to turn about and also to move about a little in order to adjust the rows. All these things have been related in detail in the Traditions.
Moreover, it is quite clear from "We have seen you turn your face over and over again towards heaven" and "We turn you towards the giblah that you like best" that the Holy Prophet used to pray for, and was expecting this change, for he himself was feeling that the term of the leadership of the Israelites had come to an end and consequently Jerusalem had also ceased to be the centre. Therefore Ka`bah which had been set up by the Prophet Abraham should be the qiblah.
"Masjid Haram" means the "Inviolable place of worship and reverence". It refers to that place of worship at Makkah which has the Ka'bah in its centre.
The Commandment "Turn your face towards the Ka'abah" does not mean that one should turn one's face exactly to the point of the Ka'abah from every part of the globe. Obviously it is very difficult for everyone to do so at all times from all places of the globe. That is why the Qur'an directs us to turn our faces towards the Ka'abah and not to the point of the Ka'abah : We should do our best to find out the exact direction of the Ka`abah : then if we are satisfied that a certain direction is most probably the correct direction, we should turn our faces towards it. But when it is not possible to ascertain the exact direction (for example, in a boat or a train, etc.) one should turn one's face to the probable right direction, and if during the prayer the correct direction is found out, one should turn one's face towards it at once.