There is some scholarly disagreement concerning this Surah [i.e. concerning where it was revealed]; the majority is however of the opinion that it was revealed in Mecca, one among the first Surahs of the Qur'an to be revealed.
Abu 'Uthman Sa'id ibn Muhammad ibn Ahmad al-Zahid informed us> his grandfather>Abu 'Amr al-Hiri> Ibrahim ibn al-Harith and 'Ali ibn Sahl ibn al-Mughirah who said: Yahya ibn Abi Bukayr informed us> Isra'il> Abu Ishaq> Abu Maysarah ['Amr ibn Shurahbil] who said: “The Messenger of Allah, Allah bless him and give him peace, whenever he went out, used to hear someone calling him 'O Muhammad!' And whenever he heard this, he used to flee. Waraqah ibn Nawfal advised the Prophet to remain in his place when the caller calls him so that he hears what he has to tell him. And so when he went out, he heard the calling: 'O Muhammad!' He said: 'Here I am! At your service!' The caller said: 'Say: I bear witness that there is no god but Allah and I bear witness that Muhammad is the Messenger of Allah'. Then he said: 'Say (Praise be to Allah, Lord of the Worlds, the Beneficent, the Merciful. Owner of the Day of Judgement…)' and he read until the end of the Opening of the Book”. This is also the opinion of 'Ali ibn Abi Talib.
Abu Ishaq Ahmad ibn Muhammad, the Qur'anic commentator, informed us>al-Hasan ibn Ja'far, the commentator who said: Abu'l-Hasan ibn Muhammad ibn Mahmud al-Marwazi> 'Abd Allah ibn Mahmud al-Sa'di> Abu Yahya al-Qasri> Marwan ibn Mu'awiyah> al-'Ala' ibn al-Musayyab> al-Fudayl ibn 'Amr> 'Ali ibn Abi Talib who said: “The Opening of the Book was revealed in Mecca from a treasure beneath the divine Throne”.
And through the same chain of transmission> al-Sa'di who said: 'Amr ibn Salih informed us> his father> al-Kalbi> Abu Salih> ibn 'Abbas who said: “The Prophet, Allah bless him and give him peace, stood up once in Mecca and said: 'In the Name of Allah, the Beneficent, the Merciful. Praise be to Allah, Lord of the Worlds'. The people of Quraysh said: 'May Allah strike your mouth' or something to this effect”. This was related by al-Hasan and Qatadah.
But according to Mujahid, the Opening of the Book was revealed in Medina. About this opinion al-Husayn ibn al-Fadl said: “Every scholar has a lapse, and this is one lapse from Mujahid, since he is the only scholar who holds this opinion while all the other scholars disagree with him”. What makes the Opening of the Book categorically a Meccan Surah is the saying of Allah, exalted is He: (We have given thee seven of the oft-repeated (verses) and the great Qur'an), i.e. the Opening of the Book.
Muhammad ibn 'Abd al-Rahman al-Nahwi informed us> Muhammad ibn Ahmad ibn 'Ali al-Hiri> Ahmad ibn 'Ali ibn al-Muthanna> Yahya ibn Ayyub> Isma'il ibn Ja'far> al-'Ala'> his father> Abu Hurayrah who said: “When Ubayy ibn Ka'b finished reading the Opening of the Book to him, the Messenger of Allah, Allah bless him and give him peace, said: 'By Him in Whose Hand is my soul, Allah has not revealed the like of it in the Torah, the Gospel, the Psalm or in the Qur'an. Verily, I was given the seven oft-repeated [i.e. al-Fatihah] and the great Qur'an' ”.
Furthermore, there is no disagreement that Surah al-Hijr was revealed in Mecca. It follows therefore that Allah would not mention His bounty on the Prophet for giving him the Opening of the Book while in Mecca and then reveal this to him in Medina. Again, one cannot possibly say that Allah's Messenger, Allah bless him and give him peace, stayed over ten years in Mecca and prayed during this time without the Opening of the Book. This is inconceivable.