Not a few months had yet passed since the migration of the Prophet to Madina when the Jews rose to oppose him. Exactly in the seventeenth month of migration a mandatory Divine command came that from then onwards the 'qiblah' of the Muslims would be the Ka'bah and while offering their prayers they should turn their faces to Masjidul Haram.
Details of the above event: During the thirteen years of his prophetic mission in Makkah the Prophet used to offer his prayers with his face towards 'Baytul Maqdis'(Jerusalem) and even after his migration to Madina the Divine order was that 'Baytul Maqdis' would continue to be the 'qiblah' and while offering their prayers the Muslims should also turn their faces to the same 'qiblah' to which the Jews turned theirs. This was in itself a sort of collaboration and a means of bringing the two religions -one old and the other new-nearer to each other. But the Jews became panicky on account of the advancement of the Muslims, because their ever-increasing successes went to show that very soon the religion of Islam would spread to the entire Peninsula and the strength and influence of the Jews would come to an end. They, therefore, began indulging in obstructionist activities and hurt the Muslims and their dignified leader in many ways. Amongst other things they put forward the question of offering prayers facing 'Baytul Maqdis' and said: "Muhammad claims that his is an independent religion and his law supersedes all previous laws, but he does not yet have an independent 'qiblah' and offers his prayers facing the 'qiblah' of the Jews".
This news hurt the Prophet. He came out of his house at midnight and looked at the sky. He was awaiting revelation.
In the meantime an order was revealed to him as contained in the following verse:
Many a time We have seen you turn your face towards heaven. We will make you turn towards a 'qiblah' that will please you. (Surah al-Baqarah, 2:144)
It appears from the verses of the Qur'an that change of qiblah was not due only to the objection of the Jews, but there was also another reason for it. It was that the matter possessed an aspect of test. The intention was that the true believers and those who were not sincere in their faith should be identified and the Prophet should fully recognize such persons, because the second order, in obedience to which he turned his face towards Masjidul Haram, while performing prayers, was the sign of faith in the new religion and disobedience and delay is a sign of double-mindedness and hypocrisy. The Qur'an itself mentions this fact clearly in the following verse:
We decreed your former qiblah only in order that We might know the Prophet's true adherents and those who were to disown him. It was indeed a hard test, but not for those whom Allah guided. (Surah al-Baqarah, 2:143 )
No doubt, there are other reasons also for this change which we find from the history of Islam and from a study of the conditions then prevailing in the Peninsula, for example:
1 The Ka'bah, which had been constructed by Prophet Ibrahim, was respected by the entire Arab society. To declare such a place the 'qiblah' ensured satisfaction of the Arabs in general and attracted them towards Islam. And there could be no target sublimer than that the obstinate polytheists who were far behind the caravan of civilization should embrace the true faith, and Islam should spread through them in all parts of the world.
2. There was no hope that the Jews of those days would embrace Islam and it, therefore, appeared necessary that the Muslims should remain at a distance from them, because they indulged in obstructionist activities and wasted the time of the Prophet by putting forward knotty questions, whereby, according to their own thinking, they displayed their knowledge and wisdom. Change of qiblah was one of the manifestations of seeking distance from the Jews, just as fasting on the day of 'Ashurah' (10th of Muharram) was abolished for that very purpose. Before the advent of Islam the Jews used to fast on the day of 'Ashurah' and the Prophet and the Muslims had also been ordered to fast on that day. Later, however, orders regarding fasting on 'Ashurah' day were withdrawn and instead fasting during the month of Ramadan was made obligatory.
After all, Islam, which is superior to other religions in all respects, should manifest itself in such a way that the points of its perfection and superiority should become absolutely clear.
On account of these reasons the Archangel Jibreel came when the Prophet had already performed two rak'ats of noon prayers and communicated to him the Divine command that he should thence forward turn to Masjidul Haram. In some of the narratives it has been said that the Archangel held the hand of the Prophet and turned him to Masjidul Haram. Men and women who were present in the mosque followed suit and from that day onwards the Ka'bah became the permanent qiblah of the Muslims.
MIRACULOUS KNOWLEDGE OF THE PROPHET
According to the computation of the former astronomers Madina lies at a latitude of 25 degrees and at a longitude of 75 degrees and 20 points. According to this computation the direction of qiblah as determined for Madina was not in confirmity with the Prophet's 'mehrab' (place of offering prayers) which is still in its original position. This difference was surprising for some experts and at times they offered explanation to remove the difference.
However, recently Sardar Kabuli, the famous scientist has proved, according to modern computations, that Madina is at a latitude of 24 degrees and 75 points and at a longitude of 39 degrees and 59 points.
The result of this computation turned out to be this: The qiblah of Madina inclines 45 degrees from the southern point and this extraction tallies exactly with the position of the Prophet's pulpit. This in itself is a scientific miracle because in those times, no scientific instruments were available, and there was nothing like computation. The Prophet while offering prayers, turned from Baytul Maqdis to the Ka'bah in such a way that there was not the least deviation from the direction of Ka'bah and as has been stated above the Archangel Jibreel held his hand and turned him to the Ka'bah.
 Tuhfatul Ajillah fi Ma'refatil qiblah, page 71.
 Man la Yahdaruhul Faqih, vol. I, page 88.
 The incident of the Prophet turning from Baytul Maqdis to the Ka'bah, while ofering prayers, has been quoted by Hur Amili in Wasa'il. (chapters on Qiblah, vol. III, page 218)