Surely the requirement to pray in a certain direction is only found in hadith… Nope.
Surah Al-Baqara (The Cow) 2:142-144
THE WEAK-MINDED among people will say, “What has turned them away from the direction of prayer which they have hitherto observed?”116 Say: “God’s is the east and the west; He guides whom He wills onto a straight way.”117
And thus have We willed you to be a community of the middle way,118 so that [with your lives] you might bear witness to the truth before all mankind, and that the Apostle might bear witness to it before you.119
And it is only to the end that We might make a clear distinction between those who follow the Apostle and those who turn about on their heels that We have appointed [for this community] the direction of prayer which thou [O Prophet] hast formerly observed: for this was indeed a hard test for all but those whom God has guided aright.120 But God will surely not lose sight of your faith – for, behold, God is most compassionate towards man, a dispenser of grace.
116 Before his call to prophethood, and during the early Meccan period of his ministry, the Prophet – and his community with him – used to turn in prayer towards the Ka’bah. This was not prompted by any specific revelation, but was obviously due to the fact that the Ka’bah – although it had in the meantime been filled with various idols to which the pre-Islamic Arabs paid homage – was always regarded as the first temple ever dedicated to the One God (cf. 3:96). Since he was aware of the sanctity of Jerusalem – the other holy centre of the unitarian faith – the Prophet prayed, as a rule, before the southern wall of the Ka’bah, towards the north, so as to face both the Ka’bah and Jerusalem. After the exodus to Medina he continued to pray northwards, with only Jerusalem as his qiblah (direction of prayer). About sixteen months after his arrival at Medina, however, he received a revelation (verses 142-150 of this surah) which definitively established the Ka’bah as the qiblah of the followers of the Qur’an. This “abandonment” of Jerusalem obviously displeased the Jews of Medina, who must have felt gratified when they saw the Muslims praying towards their holy city; and it is to them that the opening sentence of this passage refers. If one considers the matter from the historical point of view, there had never been any change in the divine commandments relating to the qiblah: there had simply been no ordinance whatever in this respect before verses 142-150 were revealed. Their logical connection with the preceding passages, which deal, in the main, with Abraham and his creed, lies in the fact that it was Abraham who erected the earliest structure of the temple which later came to be known as the Ka’bah.
117 Or: “He guides onto a straight way him that wills [to be guided]”.
118 Lit., “middlemost community” – i.e., a community that keeps an equitable balance between extremes and is realistic in its appreciation of man’s nature and possibilities, rejecting both licentiousness and exaggerated asceticism. In tune with its oft-repeated call to moderation in every aspect of life, the Qur’an exhorts the believers not to place too great an emphasis on the physical and material aspects of their lives, but postulates, at the same time, that man’s urges and desires relating to this “life of the flesh” are God-willed and, therefore, legitimate. On further analysis, the expression “a community of the middle way” might be said to summarize, as it were, the Islamic attitude towards the problem of man’s existence as such: a denial of the view that there is an inherent conflict between the spirit and the flesh, and a bold affirmation of the natural, God-willed unity in this twofold aspect of human life. This balanced attitude, peculiar to Islam, flows directly from the concept of God’s oneness and, hence, of the unity of purpose underlying all His creation: and thus, the mention of the “community of the middle way” at this place is a fitting introduction to the theme of the Ka’bah, a symbol of God’s oneness.
119 I.e., “that your way of life be an example to all mankind, just as the Apostle is an example to you”.
120 I.e., “whom He has given understanding” (Razi). The “hard test” (kabirah) consisted in the fact that ever since their exodus to Medina the Muslims had become accustomed to praying towards Jerusalem – associated in their minds with the teachings of most of the earlier prophets mentioned in the Qur’an – and were now called upon to turn in their prayers towards the Ka’bah, which at that time (in the second year after the hijrah) was still used by the pagan Quraysh as a shrine dedicated to the worship of their numerous idols. As against this, the Qur’an states that true believers would not find it difficult to adopt the Ka’bah once again as their qiblah: they would instinctively realize the divine wisdom underlying this commandment which established Abraham’s Temple as a symbol of God’s oneness and a focal point of the ideological unity of Islam. (See also note 116 above.)
We have seen thee [O Prophet] often turn thy face towards heaven [for guidance]: and now We shall indeed make thee turn in prayer in a direction which will fulfil thy desire. Turn, then, thy face towards the Inviolable House of Worship; and wherever you all may be, turn your faces towards it [in prayer].
And, verily, those who have been vouchsafed revelation aforetime know well that this
[commandment] comes in truth from their Sustainer; and God is not unaware of what they do.