Even before Allah Ta‘ala revealed the divine commandment of changing the direction of the qiblah, He kindled the yearning and desire in the heart of Rasulullah (sallallahu ‘alaihi wasallam) to face the Ka’bah Shareef while performing salaah. Hence, Rasulullah (sallallahu ‘alaihi wasallam) would frequently raise his mubaarak gaze to the skies in anticipation of the divine commandment directing him to turn towards the Ka’bah Shareef for salaah.
Subsequently, on the 15th of Sha’baan in the year 2 AH, the following verse was revealed:
فَوَلِّ وَجْهَكَ شَطْرَ الْمَسْجِدِ الْحَرَامِ
So turn your face towards the direction of Musjid-ul-Haraam. (Surah Baqarah v. 144)
Allah Ta‘ala has explained in detail the law of changing the direction of the qiblah in the beginning verses of the second para of the Qur’aan Majeed, together with mentioning the hidden secrets and wisdom behind this law. For those who wish to find out the details, they may refer to the relevant kitaabs of Tafseer.
(Extracted from Seeratul Mustafa 1/462-463)